Search in sources :

Example 6 with Vendor

use of jakarta.nosql.tck.entities.Vendor in project jnosql-diana by eclipse.

the class DocumentRepositoryProxyPaginationTest method shouldFindByStringWhenFieldIsSet.

@Test
public void shouldFindByStringWhenFieldIsSet() {
    Vendor vendor = new Vendor("vendor");
    vendor.setPrefixes(Collections.singleton("prefix"));
    when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(vendor));
    Pagination pagination = getPagination();
    vendorRepository.findByPrefixes("prefix", pagination);
    ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
    verify(template).singleResult(captor.capture());
    DocumentQuery query = captor.getValue();
    DocumentCondition condition = query.getCondition().get();
    assertEquals("vendors", query.getDocumentCollection());
    assertEquals(EQUALS, condition.getCondition());
    assertEquals(Document.of("prefixes", "prefix"), condition.getDocument());
    assertEquals(pagination.getSkip(), query.getSkip());
    assertEquals(pagination.getLimit(), query.getLimit());
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Pagination(jakarta.nosql.mapping.Pagination) Vendor(jakarta.nosql.tck.entities.Vendor) DocumentCondition(jakarta.nosql.document.DocumentCondition) Test(org.junit.jupiter.api.Test)

Example 7 with Vendor

use of jakarta.nosql.tck.entities.Vendor in project jnosql-diana by eclipse.

the class DocumentRepositoryProxyTest method shouldFindByStringWhenFieldIsSet.

@Test
public void shouldFindByStringWhenFieldIsSet() {
    Vendor vendor = new Vendor("vendor");
    vendor.setPrefixes(Collections.singleton("prefix"));
    when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(vendor));
    vendorRepository.findByPrefixes("prefix");
    ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
    verify(template).singleResult(captor.capture());
    DocumentQuery query = captor.getValue();
    DocumentCondition condition = query.getCondition().get();
    assertEquals("vendors", query.getDocumentCollection());
    assertEquals(EQUALS, condition.getCondition());
    assertEquals(Document.of("prefixes", "prefix"), condition.getDocument());
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Vendor(jakarta.nosql.tck.entities.Vendor) DocumentCondition(jakarta.nosql.document.DocumentCondition) Test(org.junit.jupiter.api.Test)

Example 8 with Vendor

use of jakarta.nosql.tck.entities.Vendor in project jnosql-diana by eclipse.

the class ColumnRepositoryProxyPaginationTest method shouldFindByStringWhenFieldIsSet.

@Test
public void shouldFindByStringWhenFieldIsSet() {
    Vendor vendor = new Vendor("vendor");
    vendor.setPrefixes(Collections.singleton("prefix"));
    when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of(vendor));
    Pagination pagination = getPagination();
    vendorRepository.findByPrefixes("prefix", pagination);
    ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
    verify(template).singleResult(captor.capture());
    ColumnQuery query = captor.getValue();
    ColumnCondition condition = query.getCondition().get();
    assertEquals("vendors", query.getColumnFamily());
    assertEquals(EQUALS, condition.getCondition());
    assertEquals(Column.of("prefixes", "prefix"), condition.getColumn());
    assertEquals(pagination.getSkip(), query.getSkip());
    assertEquals(pagination.getLimit(), query.getLimit());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Pagination(jakarta.nosql.mapping.Pagination) Vendor(jakarta.nosql.tck.entities.Vendor) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 9 with Vendor

use of jakarta.nosql.tck.entities.Vendor in project jnosql-diana by eclipse.

the class ColumnRepositoryProxyPaginationTest method shouldFindByIn.

@Test
public void shouldFindByIn() {
    Vendor vendor = new Vendor("vendor");
    vendor.setPrefixes(Collections.singleton("prefix"));
    when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of(vendor));
    Pagination pagination = getPagination();
    vendorRepository.findByPrefixesIn(singletonList("prefix"), pagination);
    ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
    verify(template).singleResult(captor.capture());
    ColumnQuery query = captor.getValue();
    ColumnCondition condition = query.getCondition().get();
    assertEquals("vendors", query.getColumnFamily());
    assertEquals(IN, condition.getCondition());
    assertEquals(pagination.getSkip(), query.getSkip());
    assertEquals(pagination.getLimit(), query.getLimit());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Pagination(jakarta.nosql.mapping.Pagination) Vendor(jakarta.nosql.tck.entities.Vendor) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 10 with Vendor

use of jakarta.nosql.tck.entities.Vendor in project jnosql-diana by eclipse.

the class DefaultColumnEntityConverterTest method shouldConvertAndDoNotUseUnmodifiableCollection.

@Test
public void shouldConvertAndDoNotUseUnmodifiableCollection() {
    ColumnEntity entity = ColumnEntity.of("vendors");
    entity.add("name", "name");
    entity.add("prefixes", Arrays.asList("value", "value2"));
    Vendor vendor = converter.toEntity(entity);
    vendor.add("value3");
    Assertions.assertEquals(3, vendor.getPrefixes().size());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Vendor(jakarta.nosql.tck.entities.Vendor) Test(org.junit.jupiter.api.Test)

Aggregations

Vendor (jakarta.nosql.tck.entities.Vendor)10 Test (org.junit.jupiter.api.Test)10 ColumnCondition (jakarta.nosql.column.ColumnCondition)4 ColumnQuery (jakarta.nosql.column.ColumnQuery)4 DocumentCondition (jakarta.nosql.document.DocumentCondition)4 DocumentQuery (jakarta.nosql.document.DocumentQuery)4 Pagination (jakarta.nosql.mapping.Pagination)4 ColumnEntity (jakarta.nosql.column.ColumnEntity)1 DocumentEntity (jakarta.nosql.document.DocumentEntity)1