Search in sources :

Example 1 with SystemCodeListResponse

use of gov.ca.cwds.rest.api.domain.cms.SystemCodeListResponse in project API by ca-cwds.

the class SystemCodeService method listOfSystemCodes.

/**
   * 
   * @param foreignKeyMetaTable the foreignKey to System Meta Table
   * @return the response containing List of Values from System Code Table that map to the
   *         primaryKey
   */
private Response listOfSystemCodes(Serializable foreignKeyMetaTable) {
    gov.ca.cwds.data.persistence.cms.SystemCode[] systemCodes = findByCriteria(foreignKeyMetaTable);
    ImmutableSet.Builder<SystemCode> builder = ImmutableSet.builder();
    for (gov.ca.cwds.data.persistence.cms.SystemCode systemCode : systemCodes) {
        if (systemCode != null) {
            builder.add(new gov.ca.cwds.rest.api.domain.cms.SystemCode(systemCode));
        }
    }
    Set<SystemCode> sysCodes = builder.build();
    return new SystemCodeListResponse(sysCodes);
}
Also used : SystemCode(gov.ca.cwds.rest.api.domain.cms.SystemCode) SystemCodeListResponse(gov.ca.cwds.rest.api.domain.cms.SystemCodeListResponse) ImmutableSet(com.google.common.collect.ImmutableSet) SystemCode(gov.ca.cwds.rest.api.domain.cms.SystemCode)

Example 2 with SystemCodeListResponse

use of gov.ca.cwds.rest.api.domain.cms.SystemCodeListResponse in project API by ca-cwds.

the class SystemCodeServiceTest method findReturnsEmptyWhenNotFound.

@Test
public void findReturnsEmptyWhenNotFound() throws Exception {
    gov.ca.cwds.data.persistence.cms.SystemCode[] foundSysCodes = new gov.ca.cwds.data.persistence.cms.SystemCode[0];
    when(systemCodeDao.findByForeignKeyMetaTable("ABC1234567")).thenReturn(foundSysCodes);
    Response found = systemCodeService.find("ABC1234567");
    SystemCodeListResponse expected = new SystemCodeListResponse(new HashSet<SystemCode>());
    assertEquals(found, expected);
}
Also used : SystemCodeListResponse(gov.ca.cwds.rest.api.domain.cms.SystemCodeListResponse) Response(gov.ca.cwds.rest.api.Response) SystemMetaListResponse(gov.ca.cwds.rest.api.domain.cms.SystemMetaListResponse) SystemCode(gov.ca.cwds.rest.api.domain.cms.SystemCode) SystemCodeListResponse(gov.ca.cwds.rest.api.domain.cms.SystemCodeListResponse) Test(org.junit.Test)

Example 3 with SystemCodeListResponse

use of gov.ca.cwds.rest.api.domain.cms.SystemCodeListResponse in project API by ca-cwds.

the class SystemCodeServiceTest method findReturnsCorrectEntitySystemCodes.

@Test
public void findReturnsCorrectEntitySystemCodes() throws Exception {
    String id = "CNTRY_C";
    SystemCode validSysCode = MAPPER.readValue(fixture("fixtures/domain/legacy/SystemCode/valid/valid.json"), SystemCode.class);
    gov.ca.cwds.data.persistence.cms.SystemCode systemCode = new gov.ca.cwds.data.persistence.cms.SystemCode((short) 471, (short) 0, "N", "  ", "Albania", "AB  ", "0000000000", "CNTRY_C ", "     ");
    gov.ca.cwds.data.persistence.cms.SystemCode[] foundSysCodes = new gov.ca.cwds.data.persistence.cms.SystemCode[1];
    foundSysCodes[0] = systemCode;
    ImmutableSet.Builder<SystemCode> builder = ImmutableSet.builder();
    builder.add(validSysCode);
    Set<SystemCode> expectedSysCodes = builder.build();
    SystemCodeListResponse expected = new SystemCodeListResponse(expectedSysCodes);
    when(systemCodeService.findByCriteria(id)).thenReturn(foundSysCodes);
    SystemCodeListResponse found = (SystemCodeListResponse) systemCodeService.find(id);
    assertThat(found, is(expected));
}
Also used : SystemCode(gov.ca.cwds.rest.api.domain.cms.SystemCode) SystemCodeListResponse(gov.ca.cwds.rest.api.domain.cms.SystemCodeListResponse) ImmutableSet(com.google.common.collect.ImmutableSet) Test(org.junit.Test)

Aggregations

SystemCode (gov.ca.cwds.rest.api.domain.cms.SystemCode)3 SystemCodeListResponse (gov.ca.cwds.rest.api.domain.cms.SystemCodeListResponse)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Test (org.junit.Test)2 Response (gov.ca.cwds.rest.api.Response)1 SystemMetaListResponse (gov.ca.cwds.rest.api.domain.cms.SystemMetaListResponse)1