Skip to content

Commit

Permalink
Add query in test
Browse files Browse the repository at this point in the history
  • Loading branch information
furlaneto committed Feb 12, 2018
1 parent 899271c commit da2ab0b
Showing 1 changed file with 32 additions and 0 deletions.
Expand Up @@ -33,6 +33,8 @@
import java.util.Random;
import java.util.function.Consumer;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import static java.util.Arrays.asList;
import static java.util.Collections.singletonMap;
Expand Down Expand Up @@ -292,6 +294,24 @@ public void shouldQueryLesserEqualsThan() {
assertTrue(entityManager.select(query3).size() == 1);
}

@Test
public void shouldQueryIn() {
List<DocumentEntity> entities = StreamSupport.stream(entityManager.insert(getEntities()).spliterator(), false)
.collect(Collectors.toList());

DocumentQuery query = select().from(COLLECTION_NAME)
.where("city").in(asList("Salvador", "Assis"))
.build();
assertTrue(entityManager.select(query).size() == 2);

DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME)
.where("city").in(asList("Salvador", "Assis", "Sao Paulo"))
.build();
entityManager.delete(deleteQuery);

assertTrue(entityManager.select(query).isEmpty());
}

@Test
public void shouldLive() throws InterruptedException {
List<DocumentEntity> entities = new ArrayList<>();
Expand Down Expand Up @@ -357,4 +377,16 @@ private DocumentEntity getEntity() {
documents.forEach(entity::add);
return entity;
}

private List<DocumentEntity> getEntities() {
DocumentEntity otavio = DocumentEntity.of(COLLECTION_NAME);
otavio.add(Document.of("name", "Otavio"));
otavio.add(Document.of("city", "Sao Paulo"));

DocumentEntity lucas = DocumentEntity.of(COLLECTION_NAME);
lucas.add(Document.of("name", "Lucas"));
lucas.add(Document.of("city", "Assis"));

return asList(getEntity(), otavio, lucas);
}
}

0 comments on commit da2ab0b

Please sign in to comment.