Search in sources :

Example 1 with SDBMetadataResult

use of com.nike.cerberus.domain.SDBMetadataResult in project cerberus by Nike-Inc.

the class MetadataServiceTest method test_that_get_sdb_metadata_properly_sets_result_metadata.

@Test
public void test_that_get_sdb_metadata_properly_sets_result_metadata() {
    int limit = 5;
    int offset = 0;
    int totalSDBs = 20;
    when(safeDepositBoxService.getTotalNumberOfSafeDepositBoxes()).thenReturn(totalSDBs);
    SDBMetadata sdbMD = new SDBMetadata();
    doReturn(Arrays.asList(sdbMD)).when(metadataServiceSpy).getSDBMetadataList(limit, offset, null);
    SDBMetadataResult actual = metadataServiceSpy.getSDBMetadata(limit, offset, null);
    assertEquals("expected actual limit to be passed in limit", limit, actual.getLimit());
    assertEquals("expected actual offset to be passed in offset", offset, actual.getOffset());
    assertEquals("expected next offset to be limit + offset", limit + offset, actual.getNextOffset());
    assertEquals("expected there to be another page of results", true, actual.isHasNext());
    assertEquals("expected the sdb count to equal 1", 1, actual.getSdbCountInResult());
    assertEquals("expected total sdbs to equal the sdb total count", totalSDBs, actual.getTotalSDBCount());
}
Also used : SDBMetadata(com.nike.cerberus.domain.SDBMetadata) SDBMetadataResult(com.nike.cerberus.domain.SDBMetadataResult) Test(org.junit.Test)

Example 2 with SDBMetadataResult

use of com.nike.cerberus.domain.SDBMetadataResult in project cerberus by Nike-Inc.

the class MetadataServiceTest method test_that_get_sdb_metadata_set_has_next_to_no_when_done_paging.

@Test
public void test_that_get_sdb_metadata_set_has_next_to_no_when_done_paging() {
    int limit = 5;
    int offset = 15;
    int totalSDBs = 20;
    when(safeDepositBoxService.getTotalNumberOfSafeDepositBoxes()).thenReturn(totalSDBs);
    doReturn(Arrays.asList(new SDBMetadata())).when(metadataServiceSpy).getSDBMetadataList(limit, offset, null);
    SDBMetadataResult actual = metadataServiceSpy.getSDBMetadata(limit, offset, null);
    assertEquals("expected actual limit to be passed in limit", limit, actual.getLimit());
    assertEquals("expected actual offset to be passed in offset", offset, actual.getOffset());
    assertEquals("expected next offset to be 0 because no more paging", 0, actual.getNextOffset());
    assertEquals("expected there to be another page of results", false, actual.isHasNext());
    assertEquals("expected the sdb count to equal 1", 1, actual.getSdbCountInResult());
    assertEquals("expected total sdbs to equal the sdb total count", totalSDBs, actual.getTotalSDBCount());
}
Also used : SDBMetadata(com.nike.cerberus.domain.SDBMetadata) SDBMetadataResult(com.nike.cerberus.domain.SDBMetadataResult) Test(org.junit.Test)

Example 3 with SDBMetadataResult

use of com.nike.cerberus.domain.SDBMetadataResult in project cerberus by Nike-Inc.

the class SdbMetadataControllerTest method testGetMetadata.

@Test
public void testGetMetadata() {
    SDBMetadataResult sdbMetadataResultMock = Mockito.mock(SDBMetadataResult.class);
    Mockito.when(metadataService.getSDBMetadata(1, 2, "sdbNameFilter")).thenReturn(sdbMetadataResultMock);
    SDBMetadataResult sdbMetadataResult = sdbMetadataController.getMetadata(1, 2, "sdbNameFilter");
    Assert.assertSame(sdbMetadataResultMock, sdbMetadataResult);
}
Also used : SDBMetadataResult(com.nike.cerberus.domain.SDBMetadataResult) Test(org.junit.Test)

Aggregations

SDBMetadataResult (com.nike.cerberus.domain.SDBMetadataResult)3 Test (org.junit.Test)3 SDBMetadata (com.nike.cerberus.domain.SDBMetadata)2