Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase test at JNoSQL communication #453

Merged
merged 21 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;


Expand All @@ -36,11 +37,25 @@ public void setUp() {
}

@Test
public void shouldNotEditColumns() {
void shouldNotEditColumns() {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
List<String> columns = query.columns();
assertTrue(columns.isEmpty());
columns.clear();
});
}

@Test
void shouldHasCode(){
var query =ColumnDeleteQuery.delete().from("columnFamily").build();
var query1 =ColumnDeleteQuery.delete().from("columnFamily").build();
assertThat(query.hashCode()).isEqualTo(query1.hashCode());
}

@Test
void shouldEquals(){
var query =ColumnDeleteQuery.delete().from("columnFamily").build();
var query1 =ColumnDeleteQuery.delete().from("columnFamily").build();
assertThat(query).isEqualTo(query1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void setUp() {
}

@Test
public void shouldNotRemoveColumns() {
void shouldNotRemoveColumns() {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
List<String> columns = query.columns();
assertTrue(columns.isEmpty());
Expand All @@ -48,7 +48,7 @@ public void shouldNotRemoveColumns() {
}

@Test
public void shouldNotRemoveSort() {
void shouldNotRemoveSort() {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
List<Sort> sorts = query.sorts();
assertTrue(sorts.isEmpty());
Expand All @@ -57,7 +57,7 @@ public void shouldNotRemoveSort() {
}

@Test
public void shouldConvertCountyBy() {
void shouldConvertCountyBy() {
ColumnQuery query = ColumnQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();
Expand All @@ -73,7 +73,7 @@ public void shouldConvertCountyBy() {
}

@Test
public void shouldConvertExistsBy() {
void shouldConvertExistsBy() {
ColumnQuery query = ColumnQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();
Expand All @@ -87,4 +87,28 @@ public void shouldConvertExistsBy() {
ColumnCondition condition = countQuery.condition().orElseThrow();
Assertions.assertEquals(Condition.EQUALS, condition.condition());
}

@Test
void shouldHasCode(){
ColumnQuery query = ColumnQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();
ColumnQuery query2 = ColumnQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();

Assertions.assertEquals(query.hashCode(), query2.hashCode());
}

@Test
void shouldEquals(){
ColumnQuery query = ColumnQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();
ColumnQuery query2 = ColumnQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();

Assertions.assertEquals(query, query2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.eclipse.jnosql.communication;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -164,4 +165,18 @@ void shouldConvertMapIgnoringKeyValue() {
}).isInstanceOf(UnsupportedOperationException.class)
.hasMessage("The type TypeReference{type=java.util.Map<java.lang.String, java.util.List<java.lang.String>>} is not supported");
}

@Test
void shouldHasCode(){
var value = Value.of(asList(10, 20, 30));
var valueB = Value.of(asList(10, 20, 30));
Assertions.assertThat(value.hashCode()).isEqualTo(valueB.hashCode());
}

@Test
void shouldEquals(){
var value = Value.of(asList(10, 20, 30));
var valueB = Value.of(asList(10, 20, 30));
Assertions.assertThat(value).isEqualTo(valueB);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.jnosql.communication.document.DocumentDeleteQuery.delete;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class DefaultDocumentDeleteQueryTest {
Expand All @@ -32,16 +34,32 @@ public class DefaultDocumentDeleteQueryTest {


@BeforeEach
public void setUp() {
query = DocumentDeleteQuery.delete().from("columnFamily").build();
void setUp() {
query = delete().from("columnFamily").build();
}

@Test
public void shouldNotEditColumns() {
void shouldNotEditColumns() {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
List<String> documents = query.documents();
assertTrue(documents.isEmpty());
documents.clear();
});
}

@Test
void shouldGenerateEquals() {
DocumentDeleteQuery query = delete().from("columnFamily").build();
DocumentDeleteQuery query2 = delete().from("columnFamily").build();

assertThat(query).isEqualTo(query2);
}

@Test
void shouldGenerateHashCode() {
DocumentDeleteQuery query = delete().from("columnFamily").build();
DocumentDeleteQuery query2 = delete().from("columnFamily").build();

assertThat(query.hashCode()).isEqualTo(query2.hashCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.jnosql.communication.document.DocumentQuery.select;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -42,7 +43,7 @@ public void setUp() {


@Test
public void shouldNotRemoveColumns() {
void shouldNotRemoveColumns() {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
List<String> columns = query.documents();
assertTrue(columns.isEmpty());
Expand All @@ -52,7 +53,7 @@ public void shouldNotRemoveColumns() {


@Test
public void shouldNotRemoveSort() {
void shouldNotRemoveSort() {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
List<Sort> sorts = query.sorts();
assertTrue(sorts.isEmpty());
Expand All @@ -61,7 +62,7 @@ public void shouldNotRemoveSort() {
}

@Test
public void shouldConvertCountyBy() {
void shouldConvertCountyBy() {
DocumentQuery query = DocumentQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();
Expand All @@ -77,7 +78,7 @@ public void shouldConvertCountyBy() {
}

@Test
public void shouldConvertExistsBy() {
void shouldConvertExistsBy() {
DocumentQuery query = DocumentQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();
Expand All @@ -91,4 +92,30 @@ public void shouldConvertExistsBy() {
DocumentCondition condition = countQuery.condition().orElseThrow();
Assertions.assertEquals(Condition.EQUALS, condition.condition());
}

@Test
void shouldGenerateEquals(){
DocumentQuery query = DocumentQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();

DocumentQuery query2 = DocumentQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();

assertThat(query).isEqualTo(query2);
}

@Test
void shouldGenerateHashCode(){
DocumentQuery query = DocumentQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();

DocumentQuery query2 = DocumentQuery.select().from("entity")
.where("name").eq("predicate")
.orderBy("name").asc().build();

assertThat(query.hashCode()).isEqualTo(query2.hashCode());
}
}
Loading