Search in sources :

Example 1 with Vendor

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

the class ColumnRepositoryProxyTest 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));
    vendorRepository.findByPrefixesIn(singletonList("prefix"));
    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());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Vendor(jakarta.nosql.tck.entities.Vendor) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 2 with Vendor

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

the class ColumnRepositoryProxyTest 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));
    vendorRepository.findByPrefixes("prefix");
    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());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Vendor(jakarta.nosql.tck.entities.Vendor) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 3 with Vendor

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

the class DefaultDocumentEntityConverterTest method shouldConvertAndDoNotUseUnmodifiableCollection.

@Test
public void shouldConvertAndDoNotUseUnmodifiableCollection() {
    DocumentEntity entity = DocumentEntity.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 : DocumentEntity(jakarta.nosql.document.DocumentEntity) Vendor(jakarta.nosql.tck.entities.Vendor) Test(org.junit.jupiter.api.Test)

Example 4 with Vendor

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

the class DocumentRepositoryProxyPaginationTest method shouldFindByIn.

@Test
public void shouldFindByIn() {
    Vendor vendor = new Vendor("vendor");
    vendor.setPrefixes(Collections.singleton("prefix"));
    when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(vendor));
    Pagination pagination = getPagination();
    vendorRepository.findByPrefixesIn(Collections.singletonList("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(IN, condition.getCondition());
    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 5 with Vendor

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

the class DocumentRepositoryProxyTest method shouldFindByIn.

@Test
public void shouldFindByIn() {
    Vendor vendor = new Vendor("vendor");
    vendor.setPrefixes(Collections.singleton("prefix"));
    when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(vendor));
    vendorRepository.findByPrefixesIn(singletonList("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(IN, condition.getCondition());
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Vendor(jakarta.nosql.tck.entities.Vendor) DocumentCondition(jakarta.nosql.document.DocumentCondition) 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