Skip to content

Commit

Permalink
test: updaste test at query
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <[email protected]>
  • Loading branch information
otaviojava committed Nov 11, 2023
1 parent 59dd076 commit 2ed8623
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
public class DocumentEntityTest {

@Test
public void shouldReturnErrorWhenNameIsNull() {
void shouldReturnErrorWhenNameIsNull() {
Assertions.assertThrows(NullPointerException.class, () -> DocumentEntity.of(null));
}

@Test
public void shouldReturnErrorWhenDocumentsIsNull() {
void shouldReturnErrorWhenDocumentsIsNull() {
Assertions.assertThrows(NullPointerException.class, () -> DocumentEntity.of("entity", null));
}

@Test
public void shouldReturnOneDocument() {
void shouldReturnOneDocument() {
DocumentEntity entity = DocumentEntity.of("entity");
assertEquals(Integer.valueOf(0), Integer.valueOf(entity.size()));
assertTrue(entity.isEmpty());
Expand All @@ -64,7 +64,7 @@ public void shouldReturnOneDocument() {
}

@Test
public void shouldDoCopy() {
void shouldDoCopy() {
DocumentEntity entity = DocumentEntity.of("entity", singletonList(Document.of("name", "name")));
DocumentEntity copy = entity.copy();
assertNotSame(entity, copy);
Expand All @@ -73,7 +73,7 @@ public void shouldDoCopy() {
}

@Test
public void shouldFindDocument() {
void shouldFindDocument() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
Optional<Document> name = entity.find("name");
Expand All @@ -84,7 +84,7 @@ public void shouldFindDocument() {
}

@Test
public void shouldReturnErrorWhenFindDocumentIsNull() {
void shouldReturnErrorWhenFindDocumentIsNull() {
Assertions.assertThrows(NullPointerException.class, () -> {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
Expand All @@ -93,15 +93,15 @@ public void shouldReturnErrorWhenFindDocumentIsNull() {
}

@Test
public void shouldRemoveDocumentByName() {
void shouldRemoveDocumentByName() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
assertTrue(entity.remove("name"));
assertTrue(entity.isEmpty());
}

@Test
public void shouldConvertToMap() {
void shouldConvertToMap() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
Map<String, Object> result = entity.toMap();
Expand All @@ -112,7 +112,7 @@ public void shouldConvertToMap() {
}

@Test
public void shouldConvertSubColumnToMap() {
void shouldConvertSubColumnToMap() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(Document.of("sub", document)));
Map<String, Object> result = entity.toMap();
Expand All @@ -123,7 +123,7 @@ public void shouldConvertSubColumnToMap() {
}

@Test
public void shouldConvertSubDocumentListToMap() {
void shouldConvertSubDocumentListToMap() {
DocumentEntity entity = DocumentEntity.of("entity");
entity.add(Document.of("_id", "id"));
List<Document> documents = asList(Document.of("name", "Ada"), Document.of("type", "type"),
Expand All @@ -140,7 +140,7 @@ public void shouldConvertSubDocumentListToMap() {
}

@Test
public void shouldConvertSubDocumentListToMap2() {
void shouldConvertSubDocumentListToMap2() {
DocumentEntity entity = DocumentEntity.of("entity");
entity.add(Document.of("_id", "id"));
List<List<Document>> documents = new ArrayList<>();
Expand All @@ -160,44 +160,44 @@ public void shouldConvertSubDocumentListToMap2() {
}

@Test
public void shouldShouldCreateANewInstance() {
void shouldShouldCreateANewInstance() {
String name = "name";
DocumentEntity entity = new DocumentEntity(name);
assertEquals(name, entity.name());
}

@Test
public void shouldCreateAnEmptyEntity() {
void shouldCreateAnEmptyEntity() {
DocumentEntity entity = new DocumentEntity("name");
assertTrue(entity.isEmpty());
}

@Test
public void shouldReturnAnErrorWhenAddANullDocument() {
void shouldReturnAnErrorWhenAddANullDocument() {
Assertions.assertThrows(NullPointerException.class, () -> {
DocumentEntity entity = new DocumentEntity("name");
entity.add(null);
});
}

@Test
public void shouldAddANewDocument() {
void shouldAddANewDocument() {
DocumentEntity entity = new DocumentEntity("name");
entity.add(Document.of("document", 12));
assertFalse(entity.isEmpty());
assertEquals(1, entity.size());
}

@Test
public void shouldReturnErrorWhenAddAnNullIterable() {
void shouldReturnErrorWhenAddAnNullIterable() {
Assertions.assertThrows(NullPointerException.class, () -> {
DocumentEntity entity = new DocumentEntity("name");
entity.addAll(null);
});
}

@Test
public void shouldAddAllDocuments() {
void shouldAddAllDocuments() {
DocumentEntity entity = new DocumentEntity("name");
entity.addAll(asList(Document.of("name", 12), Document.of("value", "value")));
assertFalse(entity.isEmpty());
Expand All @@ -206,14 +206,14 @@ public void shouldAddAllDocuments() {


@Test
public void shouldNotFindDocument() {
void shouldNotFindDocument() {
DocumentEntity entity = new DocumentEntity("name");
Optional<Document> document = entity.find("name");
assertFalse(document.isPresent());
}

@Test
public void shouldFindValue() {
void shouldFindValue() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
Optional<String> name = entity.find("name", String.class);
Expand All @@ -223,7 +223,7 @@ public void shouldFindValue() {
}

@Test
public void shouldNotFindValue() {
void shouldNotFindValue() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
Optional<String> name = entity.find("not_found", String.class);
Expand All @@ -232,7 +232,7 @@ public void shouldNotFindValue() {
}

@Test
public void shouldFindTypeSupplier() {
void shouldFindTypeSupplier() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
List<String> names = entity.find("name", new TypeReference<List<String>>() {})
Expand All @@ -243,7 +243,7 @@ public void shouldFindTypeSupplier() {
}

@Test
public void shouldNotFindTypeSupplier() {
void shouldNotFindTypeSupplier() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
List<String> names = entity.find("not_find", new TypeReference<List<String>>() {})
Expand All @@ -253,15 +253,15 @@ public void shouldNotFindTypeSupplier() {
}

@Test
public void shouldRemoveByName() {
void shouldRemoveByName() {
DocumentEntity entity = new DocumentEntity("name");
entity.add(Document.of("value", 32D));
assertTrue(entity.remove("value"));
assertTrue(entity.isEmpty());
}

@Test
public void shouldNotRemoveByName() {
void shouldNotRemoveByName() {
DocumentEntity entity = new DocumentEntity("name");
entity.add(Document.of("value", 32D));

Expand All @@ -270,7 +270,7 @@ public void shouldNotRemoveByName() {
}

@Test
public void shouldReturnErrorWhenRemoveByNameIsNull() {
void shouldReturnErrorWhenRemoveByNameIsNull() {
Assertions.assertThrows(NullPointerException.class, () -> {
DocumentEntity entity = new DocumentEntity("name");
entity.remove(null);
Expand All @@ -279,7 +279,7 @@ public void shouldReturnErrorWhenRemoveByNameIsNull() {


@Test
public void shouldAddDocumentAsNameAndObject() {
void shouldAddDocumentAsNameAndObject() {
DocumentEntity entity = new DocumentEntity("documentCollection");
entity.add("name", 10);
assertEquals(1, entity.size());
Expand All @@ -289,7 +289,7 @@ public void shouldAddDocumentAsNameAndObject() {
}

@Test
public void shouldAddDocumentAsNameAndValue() {
void shouldAddDocumentAsNameAndValue() {
DocumentEntity entity = new DocumentEntity("documentCollection");
entity.add("name", Value.of(10));
assertEquals(1, entity.size());
Expand All @@ -299,23 +299,23 @@ public void shouldAddDocumentAsNameAndValue() {
}

@Test
public void shouldReturnErrorWhenAddDocumentsObjectWhenHasNullObject() {
void shouldReturnErrorWhenAddDocumentsObjectWhenHasNullObject() {
Assertions.assertThrows(NullPointerException.class, () -> {
DocumentEntity entity = new DocumentEntity("documentCollection");
entity.add("name", null);
});
}

@Test
public void shouldReturnErrorWhenAddDocumentsObjectWhenHasNullDocumentName() {
void shouldReturnErrorWhenAddDocumentsObjectWhenHasNullDocumentName() {
Assertions.assertThrows(NullPointerException.class, () -> {
DocumentEntity entity = new DocumentEntity("documentCollection");
entity.add(null, 10);
});
}

@Test
public void shouldReturnErrorWhenAddDocumentsValueWhenHasNullDocumentName() {
void shouldReturnErrorWhenAddDocumentsValueWhenHasNullDocumentName() {
Assertions.assertThrows(NullPointerException.class, () -> {
DocumentEntity entity = new DocumentEntity("documentCollection");
entity.add(null, Value.of(12));
Expand All @@ -324,7 +324,7 @@ public void shouldReturnErrorWhenAddDocumentsValueWhenHasNullDocumentName() {


@Test
public void shouldAvoidDuplicatedDocument() {
void shouldAvoidDuplicatedDocument() {
DocumentEntity entity = new DocumentEntity("documentCollection");
entity.add("name", 10);
entity.add("name", 13);
Expand All @@ -334,7 +334,7 @@ public void shouldAvoidDuplicatedDocument() {
}

@Test
public void shouldAvoidDuplicatedDocumentWhenAddList() {
void shouldAvoidDuplicatedDocumentWhenAddList() {
List<Document> documents = asList(Document.of("name", 10), Document.of("name", 13));
DocumentEntity entity = new DocumentEntity("documentCollection");
entity.addAll(documents);
Expand All @@ -343,7 +343,7 @@ public void shouldAvoidDuplicatedDocumentWhenAddList() {
}

@Test
public void shouldReturnsTheDocumentNames() {
void shouldReturnsTheDocumentNames() {
List<Document> documents = asList(Document.of("name", 10), Document.of("name2", 11),
Document.of("name3", 12), Document.of("name4", 13),
Document.of("name5", 14), Document.of("name5", 16));
Expand All @@ -354,7 +354,7 @@ public void shouldReturnsTheDocumentNames() {
}

@Test
public void shouldReturnsTheDocumentValues() {
void shouldReturnsTheDocumentValues() {
List<Document> documents = asList(Document.of("name", 10), Document.of("name2", 11),
Document.of("name3", 12), Document.of("name4", 13),
Document.of("name5", 14), Document.of("name5", 16));
Expand All @@ -365,7 +365,7 @@ public void shouldReturnsTheDocumentValues() {
}

@Test
public void shouldReturnTrueWhenContainsElement() {
void shouldReturnTrueWhenContainsElement() {
List<Document> documents = asList(Document.of("name", 10), Document.of("name2", 11),
Document.of("name3", 12), Document.of("name4", 13),
Document.of("name5", 14), Document.of("name5", 16));
Expand All @@ -380,7 +380,7 @@ public void shouldReturnTrueWhenContainsElement() {
}

@Test
public void shouldReturnFalseWhenDoesNotContainElement() {
void shouldReturnFalseWhenDoesNotContainElement() {
List<Document> documents = asList(Document.of("name", 10), Document.of("name2", 11),
Document.of("name3", 12), Document.of("name4", 13),
Document.of("name5", 14), Document.of("name5", 16));
Expand All @@ -395,7 +395,7 @@ public void shouldReturnFalseWhenDoesNotContainElement() {
}

@Test
public void shouldRemoveAllElementsWhenUseClearMethod() {
void shouldRemoveAllElementsWhenUseClearMethod() {
List<Document> documents = asList(Document.of("name", 10), Document.of("name2", 11),
Document.of("name3", 12), Document.of("name4", 13),
Document.of("name5", 14), Document.of("name5", 16));
Expand All @@ -408,23 +408,23 @@ public void shouldRemoveAllElementsWhenUseClearMethod() {
}

@Test
public void shouldHashCode(){
void shouldHashCode(){
List<Document> documents = List.of(Document.of("name", 10));
var collection = DocumentEntity.of("documentCollection", documents);
var collection2 = DocumentEntity.of("documentCollection", documents);
assertThat(collection.hashCode()).isEqualTo(collection2.hashCode());
}

@Test
public void shouldEquals(){
void shouldEquals(){
List<Document> documents = List.of(Document.of("name", 10));
var collection = DocumentEntity.of("documentCollection", documents);
var collection2 = DocumentEntity.of("documentCollection", documents);
assertThat(collection).isEqualTo(collection2);
}

@Test
public void shouldToString(){
void shouldToString(){
List<Document> documents = List.of(Document.of("name", 10));
var collection = DocumentEntity.of("documentCollection", documents);
assertThat(collection.toString()).isEqualTo("DefaultDocumentEntity{documents={name=DefaultDocument" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class DefaultArrayQueryValueTest {

@Test
public void shouldReturnArrayType() {
void shouldReturnArrayType() {
ArrayQueryValue array = DefaultArrayQueryValue.of(new QueryValue<?>[]{
BooleanQueryValue.FALSE});
assertThat(array).isNotNull();
Expand All @@ -28,14 +28,14 @@ public void shouldReturnArrayType() {
}

@Test
public void shouldReturnArrayValue() {
void shouldReturnArrayValue() {
ArrayQueryValue array = DefaultArrayQueryValue.of(new QueryValue<?>[]{
BooleanQueryValue.FALSE, BooleanQueryValue.TRUE});
assertThat(array.get()).containsExactly(BooleanQueryValue.FALSE, BooleanQueryValue.TRUE);
}

@Test
public void shouldEquals(){
void shouldEquals(){
ArrayQueryValue array = DefaultArrayQueryValue.of(new QueryValue<?>[]{
BooleanQueryValue.FALSE, BooleanQueryValue.TRUE});
ArrayQueryValue arrayB = DefaultArrayQueryValue.of(new QueryValue<?>[]{
Expand All @@ -44,7 +44,7 @@ public void shouldEquals(){
}

@Test
public void shouldHashCode(){
void shouldHashCode(){
ArrayQueryValue array = DefaultArrayQueryValue.of(new QueryValue<?>[]{
BooleanQueryValue.FALSE, BooleanQueryValue.TRUE});
ArrayQueryValue arrayB = DefaultArrayQueryValue.of(new QueryValue<?>[]{
Expand All @@ -53,7 +53,7 @@ public void shouldHashCode(){
}

@Test
public void shouldToString(){
void shouldToString(){
ArrayQueryValue array = DefaultArrayQueryValue.of(new QueryValue<?>[]{
BooleanQueryValue.FALSE, BooleanQueryValue.TRUE});
assertThat(array.toString()).isEqualTo("[BooleanQueryValue{value=false}, BooleanQueryValue{value=true}]");
Expand Down
Loading

0 comments on commit 2ed8623

Please sign in to comment.