use of gov.cms.ab2d.common.dto.PropertiesDTO in project ab2d by CMSgov.
the class AdminAPIPropertiesTests method testRetrieveProperties.
@Test
@Order(1)
public void testRetrieveProperties() throws Exception {
Map<String, Object> propertyMap = new HashMap<>() {
{
put(PCP_CORE_POOL_SIZE, 10);
put(PCP_MAX_POOL_SIZE, 150);
put(PCP_SCALE_TO_MAX_TIME, 900);
put(MAINTENANCE_MODE, "false");
put(ZIP_SUPPORT_ON, "false");
put(WORKER_ENGAGEMENT, "engaged");
put(HPMS_INGESTION_ENGAGEMENT, "engaged");
put(COVERAGE_SEARCH_DISCOVERY, "idle");
put(COVERAGE_SEARCH_QUEUEING, "idle");
put(COVERAGE_SEARCH_UPDATE_MONTHS, 1);
put(COVERAGE_SEARCH_STUCK_HOURS, 24);
put(COVERAGE_SEARCH_OVERRIDE, "false");
}
};
MvcResult mvcResult = this.mockMvc.perform(get(API_PREFIX_V1 + ADMIN_PREFIX + PROPERTIES_URL).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token)).andReturn();
assertEquals(200, mvcResult.getResponse().getStatus());
String result = mvcResult.getResponse().getContentAsString();
ObjectMapper mapper = new ObjectMapper();
List<PropertiesDTO> propertiesDTOs = mapper.readValue(result, new TypeReference<>() {
});
assertEquals(12, propertiesDTOs.size());
for (PropertiesDTO propertiesDTO : propertiesDTOs) {
Object value = propertyMap.get(propertiesDTO.getKey());
assertNotNull(value);
assertEquals(value.toString(), propertiesDTO.getValue());
}
}
use of gov.cms.ab2d.common.dto.PropertiesDTO in project ab2d by CMSgov.
the class MaintenanceModeAPITests method testMaintenanceModeOn.
@Test
@Order(2)
public void testMaintenanceModeOn() throws Exception {
PropertiesDTO propertiesDTO = new PropertiesDTO();
propertiesDTO.setKey(MAINTENANCE_MODE);
propertiesDTO.setValue("true");
propertiesService.updateProperties(List.of(propertiesDTO));
this.mockMvc.perform(get(STATUS_ENDPOINT).contentType(MediaType.APPLICATION_JSON)).andExpect(status().is(200)).andExpect(jsonPath("$.maintenanceMode", Is.is("true")));
}
use of gov.cms.ab2d.common.dto.PropertiesDTO in project ab2d by CMSgov.
the class TestUtil method turnMaintenanceModeOff.
public void turnMaintenanceModeOff() {
PropertiesDTO propertiesDTO = new PropertiesDTO();
propertiesDTO.setKey(MAINTENANCE_MODE);
propertiesDTO.setValue("false");
List<PropertiesDTO> propertiesDTOs = new ArrayList<>();
propertiesDTOs.add(propertiesDTO);
propertiesService.updateProperties(propertiesDTOs);
}
use of gov.cms.ab2d.common.dto.PropertiesDTO in project ab2d by CMSgov.
the class AdminAPIMaintenanceModeTests method testSwitchMaintenanceModeOnAndOff.
@Test
public void testSwitchMaintenanceModeOnAndOff() throws Exception {
List<PropertiesDTO> propertiesDTOs = new ArrayList<>();
PropertiesDTO maintenanceModeDTO = new PropertiesDTO();
maintenanceModeDTO.setKey(MAINTENANCE_MODE);
maintenanceModeDTO.setValue("true");
propertiesDTOs.add(maintenanceModeDTO);
ObjectMapper mapper = new ObjectMapper();
this.mockMvc.perform(put(API_PREFIX_V1 + ADMIN_PREFIX + PROPERTIES_URL).contentType(MediaType.APPLICATION_JSON).content(mapper.writeValueAsString(propertiesDTOs)).header("Authorization", "Bearer " + token)).andExpect(status().is(200));
this.mockMvc.perform(get(API_PREFIX_V1 + FHIR_PREFIX + PATIENT_EXPORT_PATH).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token)).andExpect(status().is(HttpStatus.SERVICE_UNAVAILABLE.value()));
List<LoggableEvent> apiReqEvents = loggerEventRepository.load(ApiRequestEvent.class);
assertEquals(2, apiReqEvents.size());
List<LoggableEvent> apiResEvents = loggerEventRepository.load(ApiResponseEvent.class);
assertEquals(1, apiResEvents.size());
ApiResponseEvent responseEvent = (ApiResponseEvent) apiResEvents.get(0);
assertEquals(HttpStatus.SERVICE_UNAVAILABLE.value(), responseEvent.getResponseCode());
List<LoggableEvent> reloadEvents = loggerEventRepository.load(ReloadEvent.class);
assertEquals(1, reloadEvents.size());
ReloadEvent reloadEvent = (ReloadEvent) reloadEvents.get(0);
assertEquals(ReloadEvent.FileType.PROPERTIES, reloadEvent.getFileType());
assertTrue(UtilMethods.allEmpty(loggerEventRepository.load(ContractSearchEvent.class), loggerEventRepository.load(ErrorEvent.class), loggerEventRepository.load(FileEvent.class), loggerEventRepository.load(JobStatusChangeEvent.class)));
propertiesDTOs.clear();
maintenanceModeDTO.setValue("false");
propertiesDTOs.add(maintenanceModeDTO);
this.mockMvc.perform(put(API_PREFIX_V1 + ADMIN_PREFIX + PROPERTIES_URL).contentType(MediaType.APPLICATION_JSON).content(mapper.writeValueAsString(propertiesDTOs)).header("Authorization", "Bearer " + token)).andExpect(status().is(200));
this.mockMvc.perform(get(API_PREFIX_V1 + FHIR_PREFIX + PATIENT_EXPORT_PATH).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token)).andExpect(status().is(202));
}
use of gov.cms.ab2d.common.dto.PropertiesDTO in project ab2d by CMSgov.
the class PropertiesServiceImpl method addUpdatedPropertiesToList.
private void addUpdatedPropertiesToList(List<PropertiesDTO> propertiesDTOsReturn, PropertiesDTO propertiesDTO) {
Properties properties = getPropertiesByKey(propertiesDTO.getKey());
Properties mappedProperties = mapping.getModelMapper().map(propertiesDTO, Properties.class);
mappedProperties.setId(properties.getId());
Properties updatedProperties = propertiesRepository.save(mappedProperties);
log.info("Updated property {} with value {}", updatedProperties.getKey(), updatedProperties.getValue());
propertiesDTOsReturn.add(mapping.getModelMapper().map(updatedProperties, PropertiesDTO.class));
}
Aggregations