@Test(expected = IncorrectParameterException.class) public void findLatestConfigurationByAppIdTestFail() { configurationService.findConfigurationByAppIdAndVersion(INCORRECT_SQL_ID, 1); }
@Test public void findLatestConfigurationByAppIdTest() { List<ConfigurationDto> configurations = generateConfigurationDto(null, null, 1, false, false); ConfigurationDto expected = configurations.get(0); ConfigurationDto found = configurationService.findConfigurationByAppIdAndVersion(expected.getApplicationId(), 1); Assert.assertNotNull(found); }
private ConfigurationDto createDefaultConfigurationWithSchema(String appId, String groupId, String createdUsername) { ConfigurationSchemaDto schema = new ConfigurationSchemaDto(); schema.setApplicationId(appId); CTLSchemaDto ctlSchema = ctlService.getOrCreateEmptySystemSchema(createdUsername); schema.setCtlSchemaId(ctlSchema.getId()); schema.setName(DEFAULT_SCHEMA_NAME); schema.setCreatedUsername(createdUsername); ConfigurationSchemaDto savedSchema = configurationService.saveConfSchema(schema, groupId); ConfigurationDto config = configurationService.findConfigurationByAppIdAndVersion( savedSchema.getApplicationId(), savedSchema.getVersion()); if (config == null) { throw new RuntimeException("Can't find default configuration by schema id " + savedSchema.getId()); //NOSONAR } else { return config; } }
@Test public void createDefaultSchemaTest() { String id = generateApplicationDto().getId(); ConfigurationSchemaDto schema = generateConfSchemaDto(null, id, 1).get(0); ConfigurationDto config = configurationService.findConfigurationByAppIdAndVersion(id, schema.getVersion()); Assert.assertEquals(config.getStatus(), UpdateStatus.ACTIVE); }