Search in sources :

Example 1 with SystemMetaListResponse

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

the class SystemCodeService method listOfSystemMetas.

/**
   * 
   * @return the response containing List of Values from System Meta Table
   */
private Response listOfSystemMetas() {
    SystemMeta[] sysMeta = systemMetaDao.findAll();
    ImmutableSet.Builder<gov.ca.cwds.rest.api.domain.cms.SystemMeta> builder = ImmutableSet.builder();
    for (SystemMeta s : sysMeta) {
        if (s != null) {
            builder.add(new gov.ca.cwds.rest.api.domain.cms.SystemMeta(s));
        }
    }
    return new SystemMetaListResponse(builder.build());
}
Also used : SystemMetaListResponse(gov.ca.cwds.rest.api.domain.cms.SystemMetaListResponse) SystemMeta(gov.ca.cwds.data.persistence.cms.SystemMeta) ImmutableSet(com.google.common.collect.ImmutableSet)

Example 2 with SystemMetaListResponse

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

the class SystemCodeServiceTest method findReturnsCorrectEntitySystemMetas.

@Test
public void findReturnsCorrectEntitySystemMetas() throws Exception {
    String id = "";
    SystemMeta validSysMeta = MAPPER.readValue(fixture("fixtures/domain/legacy/SystemMeta/valid/valid.json"), SystemMeta.class);
    gov.ca.cwds.data.persistence.cms.SystemMeta systemMeta = new gov.ca.cwds.data.persistence.cms.SystemMeta("GVR_ENTC", "Government Entity Type", "Government Entity");
    gov.ca.cwds.data.persistence.cms.SystemMeta[] foundSysMetas = new gov.ca.cwds.data.persistence.cms.SystemMeta[1];
    foundSysMetas[0] = systemMeta;
    ImmutableSet.Builder<SystemMeta> builder = ImmutableSet.builder();
    builder.add(validSysMeta);
    Set<SystemMeta> expectedSysMetas = builder.build();
    SystemMetaListResponse expected = new SystemMetaListResponse(expectedSysMetas);
    when(systemMetaDao.findAll()).thenReturn(foundSysMetas);
    SystemMetaListResponse found = (SystemMetaListResponse) systemCodeService.find(id);
    assertThat(found, is(expected));
}
Also used : SystemMetaListResponse(gov.ca.cwds.rest.api.domain.cms.SystemMetaListResponse) SystemMeta(gov.ca.cwds.rest.api.domain.cms.SystemMeta) ImmutableSet(com.google.common.collect.ImmutableSet) Test(org.junit.Test)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)2 SystemMetaListResponse (gov.ca.cwds.rest.api.domain.cms.SystemMetaListResponse)2 SystemMeta (gov.ca.cwds.data.persistence.cms.SystemMeta)1 SystemMeta (gov.ca.cwds.rest.api.domain.cms.SystemMeta)1 Test (org.junit.Test)1