use of gov.cms.ab2d.common.dto.ContractDTO in project ab2d by CMSgov.
the class CoverageCheckPredicatesUnitTest method whenCoverageDuplicated_failCoverageDuplicationCheck.
@DisplayName("Duplicate enrollment counts cause a failure")
@Test
void whenCoverageDuplicated_failCoverageDuplicationCheck() {
Map<String, List<CoverageCount>> coverageCounts = new HashMap<>();
List<String> issues = new ArrayList<>();
CoverageNoDuplicatesCheck duplicatesCheck = new CoverageNoDuplicatesCheck(coverageService, coverageCounts, issues);
ContractDTO contract = getContractDTO();
List<CoverageCount> fakeCounts = List.of(new CoverageCount("TEST", ATTESTATION_TIME.plusMonths(0).getYear(), ATTESTATION_TIME.plusMonths(0).getMonthValue(), 1, 1, 1), new CoverageCount("TEST", ATTESTATION_TIME.plusMonths(1).getYear(), ATTESTATION_TIME.plusMonths(1).getMonthValue(), 2, 1, 1), new CoverageCount("TEST", ATTESTATION_TIME.plusMonths(1).getYear(), ATTESTATION_TIME.plusMonths(1).getMonthValue(), 2, 1, 1), new CoverageCount("TEST", ATTESTATION_TIME.plusMonths(1).getYear(), ATTESTATION_TIME.plusMonths(1).getMonthValue(), 2, 1, 1), new CoverageCount("TEST", ATTESTATION_TIME.plusMonths(2).getYear(), ATTESTATION_TIME.plusMonths(2).getMonthValue(), 3, 1, 1), new CoverageCount("TEST", ATTESTATION_TIME.plusMonths(2).getYear(), ATTESTATION_TIME.plusMonths(2).getMonthValue(), 3, 1, 1));
coverageCounts.put("TEST", fakeCounts);
assertFalse(duplicatesCheck.test(contract));
assertEquals(2, issues.size());
issues.forEach(issue -> assertTrue(issue.contains("sets of enrollment")));
}
use of gov.cms.ab2d.common.dto.ContractDTO in project ab2d by CMSgov.
the class AdminAPIPdpClientTests method getClient.
@Test
public void getClient() throws Exception {
// Ensure client is in right state first
setupClient(ENABLE_DISABLE_CLIENT, true);
MvcResult mvcResult = this.mockMvc.perform(get(API_PREFIX_V1 + ADMIN_PREFIX + CLIENT_URL + "/" + ENABLE_DISABLE_CONTRACT).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token)).andReturn();
assertEquals(200, mvcResult.getResponse().getStatus());
ObjectMapper mapper = getMapper();
String getResult = mvcResult.getResponse().getContentAsString();
PdpClientDTO pdpClientDTO = mapper.readValue(getResult, PdpClientDTO.class);
assertEquals(ENABLE_DISABLE_CLIENT, pdpClientDTO.getClientId());
assertEquals(true, pdpClientDTO.getEnabled());
ContractDTO contractDTO = pdpClientDTO.getContract();
assertEquals(ENABLE_DISABLE_CONTRACT, contractDTO.getContractNumber());
assertEquals("Test Contract Z0000", contractDTO.getContractName());
assertNotNull(contractDTO.getAttestedOn());
}
use of gov.cms.ab2d.common.dto.ContractDTO in project ab2d by CMSgov.
the class Mapping method init.
@PostConstruct
public void init() {
modelMapper = new ModelMapper();
modelMapper.getConfiguration().setSkipNullEnabled(true);
Converter<String, Role> roleDTOToRoleConverter = context -> {
if (context.getSource() == null) {
return null;
} else {
return roleService.findRoleByName(context.getSource());
}
};
Converter<Set<Role>, String> roleToRoleDTOConverter = context -> {
if (context.getSource() == null || context.getSource().isEmpty()) {
return null;
} else {
return context.getSource().iterator().next().getName();
}
};
Converter<ContractDTO, Contract> sponsorDTOSponsorConverter = new AbstractConverter<>() {
protected Contract convert(ContractDTO source) {
// NOSONAR
return contractService.getContractByContractNumber(source.getContractNumber()).get();
}
};
modelMapper.addConverter(sponsorDTOSponsorConverter);
modelMapper.createTypeMap(PdpClient.class, PdpClientDTO.class).addMappings(mapper -> mapper.map(pdpClient -> pdpClient.getContract().toDTO(), PdpClientDTO::setContract)).addMappings(mapper -> mapper.using(roleToRoleDTOConverter).map(PdpClient::getRoles, PdpClientDTO::setRole)).addMappings(mapper -> mapper.map(PdpClient::getContract, PdpClientDTO::setContract));
modelMapper.createTypeMap(PdpClientDTO.class, PdpClient.class).addMappings(mapper -> mapper.using(roleDTOToRoleConverter).map(PdpClientDTO::getRole, PdpClient::addRole)).addMappings(mapper -> mapper.map(PdpClientDTO::getClientId, PdpClient::setClientId));
}
Aggregations