use of gov.cms.ab2d.common.model.Properties 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));
}
use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.
the class PropertiesChangeDetectionTest method testChangeInProperties.
@Test
public void testChangeInProperties() {
assertEquals(autoScalingService.getCorePoolSize(), 10);
assertEquals(autoScalingService.getMaxPoolSize(), 150);
assertEquals(autoScalingService.getScaleToMaxTime(), 900.0, 0);
Properties propertiesCorePoolSize = propertiesRepository.findByKey(PCP_CORE_POOL_SIZE).get();
propertiesCorePoolSize.setValue("8");
propertiesRepository.save(propertiesCorePoolSize);
Properties propertiesMaxPoolSize = propertiesRepository.findByKey(PCP_MAX_POOL_SIZE).get();
propertiesMaxPoolSize.setValue("300");
propertiesRepository.save(propertiesMaxPoolSize);
Properties propertiesScaleToMaxTime = propertiesRepository.findByKey(PCP_SCALE_TO_MAX_TIME).get();
propertiesScaleToMaxTime.setValue("1500");
propertiesRepository.save(propertiesScaleToMaxTime);
propertiesChangeDetection.detectChanges();
assertEquals(autoScalingService.getCorePoolSize(), 8);
assertEquals(autoScalingService.getMaxPoolSize(), 300);
assertEquals(autoScalingService.getScaleToMaxTime(), 1500.0, 0);
Object valuePCPCorePoolSize = configurableEnvironment.getPropertySources().get("application").getProperty(PCP_CORE_POOL_SIZE);
assertEquals(valuePCPCorePoolSize, "8");
Object valuePCPMaxPoolSize = configurableEnvironment.getPropertySources().get("application").getProperty(PCP_MAX_POOL_SIZE);
assertEquals(valuePCPMaxPoolSize, "300");
Object valuePCPScaleToMaxTime = configurableEnvironment.getPropertySources().get("application").getProperty(PCP_SCALE_TO_MAX_TIME);
assertEquals(valuePCPScaleToMaxTime, "1500");
// Cleanup
propertiesCorePoolSize.setValue("10");
propertiesRepository.save(propertiesCorePoolSize);
propertiesMaxPoolSize.setValue("150");
propertiesRepository.save(propertiesMaxPoolSize);
propertiesScaleToMaxTime.setValue("900");
propertiesRepository.save(propertiesScaleToMaxTime);
}
use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.
the class CoveragePeriodQuartzJobTest method engageSearchWorks.
@DisplayName("Engaging coverage search works")
@Test
void engageSearchWorks() {
PropertiesService propertiesService = mock(PropertiesService.class);
when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_DISCOVERY))).thenAnswer((arg) -> {
Properties engaged = new Properties();
engaged.setKey(Constants.COVERAGE_SEARCH_DISCOVERY);
engaged.setValue("engaged");
return engaged;
});
when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_QUEUEING))).thenAnswer((arg) -> {
Properties engaged = new Properties();
engaged.setKey(Constants.COVERAGE_SEARCH_QUEUEING);
engaged.setValue("engaged");
return engaged;
});
when(propertiesService.getPropertiesByKey(eq(COVERAGE_SEARCH_OVERRIDE))).thenAnswer((arg) -> {
Properties override = new Properties();
override.setKey(COVERAGE_SEARCH_OVERRIDE);
override.setValue("true");
return override;
});
CoverageDriverStub coverageDriverStub = new CoverageDriverStub();
CoveragePeriodQuartzJob quartzJob = new CoveragePeriodQuartzJob(coverageDriverStub, propertiesService, logManager);
try {
quartzJob.executeInternal(null);
assertTrue(coverageDriverStub.discoveryCalled);
assertTrue(coverageDriverStub.queueingCalled);
} catch (JobExecutionException jobExecutionException) {
fail("could not execute normally", jobExecutionException);
}
}
use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.
the class CoveragePeriodQuartzJobTest method failingSearchesTriggerAlerts.
@DisplayName("Failing searches trigger alerts")
@Test
void failingSearchesTriggerAlerts() {
PropertiesService propertiesService = mock(PropertiesService.class);
when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_DISCOVERY))).thenAnswer((arg) -> {
Properties engaged = new Properties();
engaged.setKey(Constants.COVERAGE_SEARCH_DISCOVERY);
engaged.setValue("engaged");
return engaged;
});
when(propertiesService.getPropertiesByKey(eq(COVERAGE_SEARCH_OVERRIDE))).thenAnswer((arg) -> {
Properties override = new Properties();
override.setKey(COVERAGE_SEARCH_OVERRIDE);
override.setValue("true");
return override;
});
try {
doThrow(new RuntimeException("testing123")).when(coverageDriverMock).discoverCoveragePeriods();
CoveragePeriodQuartzJob quartzJob = new CoveragePeriodQuartzJob(coverageDriverMock, propertiesService, logManager);
JobExecutionException exception = assertThrows(JobExecutionException.class, () -> quartzJob.executeInternal(null));
assertTrue(exception.getMessage().contains("testing123"));
verify(logManager, times(1)).alert(contains("coverage period updates could not be conducted"), anyList());
} catch (Exception ex) {
fail("could not execute test due to interruption", ex);
}
}
use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.
the class BFDHealthCheckTest method testBfdComingBackUp.
@Test
public void testBfdComingBackUp() throws IOException {
// First take down, since BFD starts as up
MockBfdServiceUtils.createMockServerMetaExpectation(TEST_DIR + "meta-unknown-status.xml", MOCK_SERVER_PORT);
for (int i = 0; i < consecutiveFailuresToTakeDown; i++) {
bfdHealthCheck.checkBFDHealth();
}
MockBfdServiceUtils.reset(MOCK_SERVER_PORT);
MockBfdServiceUtils.createMockServerMetaExpectation(TEST_DIR + "meta.xml", MOCK_SERVER_PORT);
Properties maintenanceProperties = propertiesService.getPropertiesByKey(MAINTENANCE_MODE);
assertEquals("true", maintenanceProperties.getValue());
for (int i = 0; i < consecutiveSuccessesToBringUp; i++) {
bfdHealthCheck.checkBFDHealth();
}
maintenanceProperties = propertiesService.getPropertiesByKey(MAINTENANCE_MODE);
assertEquals("false", maintenanceProperties.getValue());
}
Aggregations