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);
}
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);
}
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));
}
Aggregations