Skip to content

Commit

Permalink
Service and Tests changes for Configuration Schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill380 committed Jun 23, 2016
1 parent 7de1877 commit 0300d0b
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 135 deletions.
Expand Up @@ -36,7 +36,7 @@
@Entity @Entity
@Table(name = CONFIGURATION_SCHEMA_TABLE_NAME) @Table(name = CONFIGURATION_SCHEMA_TABLE_NAME)
@OnDelete(action = OnDeleteAction.CASCADE) @OnDelete(action = OnDeleteAction.CASCADE)
public class ConfigurationSchema extends Schema<ConfigurationSchemaDto> implements Serializable { public class ConfigurationSchema extends BaseSchema<ConfigurationSchemaDto> implements Serializable {


private static final long serialVersionUID = -8854035430683210037L; private static final long serialVersionUID = -8854035430683210037L;


Expand Down Expand Up @@ -95,9 +95,6 @@ public void setOverrideSchema(String overrideSchema) {
this.overrideSchema = overrideSchema; this.overrideSchema = overrideSchema;
} }


public String getApplicationId() {
return application != null ? application.getStringId() : null;
}


@Override @Override
public ConfigurationSchemaDto toDto() { public ConfigurationSchemaDto toDto() {
Expand All @@ -118,60 +115,11 @@ protected GenericModel<ConfigurationSchemaDto> newInstance(Long id) {
return new ConfigurationSchema(id); return new ConfigurationSchema(id);
} }


@Override
public int hashCode() {
final int prime = 37;
int result = 1;
result = prime * result + super.hashCode();
result = prime * result + ((baseSchema == null) ? 0 : baseSchema.hashCode());
result = prime * result + ((protocolSchema == null) ? 0 : protocolSchema.hashCode());
result = prime * result + ((overrideSchema == null) ? 0 : overrideSchema.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (!super.equals(obj)) {
return false;
}
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ConfigurationSchema other = (ConfigurationSchema) obj;
if (baseSchema == null) {
if (other.baseSchema != null) {
return false;
}
} else if (!baseSchema.equals(other.baseSchema)) {
return false;
}
if (protocolSchema == null) {
if (other.protocolSchema != null) {
return false;
}
} else if (!protocolSchema.equals(other.protocolSchema)) {
return false;
}
if (overrideSchema == null) {
if (other.overrideSchema != null) {
return false;
}
} else if (!overrideSchema.equals(other.overrideSchema)) {
return false;
}
return true;
}


@Override @Override
public String toString() { public String toString() {
return "ConfigurationSchema [version=" + version + ", name=" + name + ", description=" return "ConfigurationSchema [version=" + version + ", name=" + name + ", description="
+ description + ", createdUsername=" + createdUsername + ", createdTime=" + createdTime + ", endpointCount=" + endpointCount + ", id=" + id + description + ", createdUsername=" + createdUsername + ", createdTime=" + createdTime + ", id=" + id
+ "]"; + "]";
} }


Expand Down
Expand Up @@ -242,12 +242,8 @@ private EndpointProfileSchemaDto createDefaultProfileSchema(String appId, String
private ConfigurationDto createDefaultConfigurationWithSchema(String appId, String groupId, String createdUsername) { private ConfigurationDto createDefaultConfigurationWithSchema(String appId, String groupId, String createdUsername) {
ConfigurationSchemaDto schema = new ConfigurationSchemaDto(); ConfigurationSchemaDto schema = new ConfigurationSchemaDto();
schema.setApplicationId(appId); schema.setApplicationId(appId);
DataSchema confSchema = new KaaSchemaFactoryImpl().createDataSchema(getStringFromFile(DEFAULT_CONFIGURATION_SCHEMA_FILE, ApplicationServiceImpl.class)); CTLSchemaDto ctlSchema = ctlService.getOrCreateEmptySystemSchema(createdUsername);
if (!confSchema.isEmpty()) { schema.setCtlSchemaId(ctlSchema.getId());
schema.setSchema(confSchema.getRawSchema());
} else {
throw new RuntimeException("Can't read default configuration schema."); //NOSONAR
}
schema.setName(DEFAULT_SCHEMA_NAME); schema.setName(DEFAULT_SCHEMA_NAME);
schema.setCreatedUsername(createdUsername); schema.setCreatedUsername(createdUsername);
ConfigurationSchemaDto savedSchema = configurationService.saveConfSchema(schema, groupId); ConfigurationSchemaDto savedSchema = configurationService.saveConfSchema(schema, groupId);
Expand Down
Expand Up @@ -32,6 +32,7 @@
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;


import org.apache.avro.Schema;
import org.apache.avro.generic.GenericRecord; import org.apache.avro.generic.GenericRecord;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.kaaproject.kaa.common.avro.GenericAvroConverter; import org.kaaproject.kaa.common.avro.GenericAvroConverter;
Expand All @@ -45,6 +46,7 @@
import org.kaaproject.kaa.common.dto.HistoryDto; import org.kaaproject.kaa.common.dto.HistoryDto;
import org.kaaproject.kaa.common.dto.UpdateStatus; import org.kaaproject.kaa.common.dto.UpdateStatus;
import org.kaaproject.kaa.common.dto.VersionDto; import org.kaaproject.kaa.common.dto.VersionDto;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaDto;
import org.kaaproject.kaa.server.common.core.algorithms.generation.DefaultRecordGenerationAlgorithm; import org.kaaproject.kaa.server.common.core.algorithms.generation.DefaultRecordGenerationAlgorithm;
import org.kaaproject.kaa.server.common.core.algorithms.generation.DefaultRecordGenerationAlgorithmImpl; import org.kaaproject.kaa.server.common.core.algorithms.generation.DefaultRecordGenerationAlgorithmImpl;
import org.kaaproject.kaa.server.common.core.algorithms.schema.SchemaCreationException; import org.kaaproject.kaa.server.common.core.algorithms.schema.SchemaCreationException;
Expand All @@ -60,6 +62,7 @@
import org.kaaproject.kaa.server.common.core.schema.DataSchema; import org.kaaproject.kaa.server.common.core.schema.DataSchema;
import org.kaaproject.kaa.server.common.core.schema.OverrideSchema; import org.kaaproject.kaa.server.common.core.schema.OverrideSchema;
import org.kaaproject.kaa.server.common.core.schema.ProtocolSchema; import org.kaaproject.kaa.server.common.core.schema.ProtocolSchema;
import org.kaaproject.kaa.server.common.dao.CTLService;
import org.kaaproject.kaa.server.common.dao.ConfigurationService; import org.kaaproject.kaa.server.common.dao.ConfigurationService;
import org.kaaproject.kaa.server.common.dao.HistoryService; import org.kaaproject.kaa.server.common.dao.HistoryService;
import org.kaaproject.kaa.server.common.dao.exception.DatabaseProcessingException; import org.kaaproject.kaa.server.common.dao.exception.DatabaseProcessingException;
Expand Down Expand Up @@ -98,6 +101,10 @@ public class ConfigurationServiceImpl implements ConfigurationService {
@Autowired @Autowired
private HistoryService historyService; private HistoryService historyService;



@Autowired
private CTLService ctlService;

@Autowired @Autowired
private SchemaGenerationAlgorithmFactory schemaGeneratorFactory; private SchemaGenerationAlgorithmFactory schemaGeneratorFactory;


Expand Down Expand Up @@ -499,7 +506,9 @@ private ChangeNotificationDto createNotification(ConfigurationDto configurationD
} }


private void generateSchemas(ConfigurationSchemaDto schema) throws SchemaCreationException { private void generateSchemas(ConfigurationSchemaDto schema) throws SchemaCreationException {
DataSchema dataSchema = new DataSchema(schema.getSchema()); CTLSchemaDto ctlSchema = ctlService.findCTLSchemaById(schema.getCtlSchemaId());
String sch = ctlService.flatExportAsString(ctlSchema);
DataSchema dataSchema = new DataSchema(sch);
if (!dataSchema.isEmpty()) { if (!dataSchema.isEmpty()) {
SchemaGenerationAlgorithm schemaGenerator = schemaGeneratorFactory.createSchemaGenerator(dataSchema); SchemaGenerationAlgorithm schemaGenerator = schemaGeneratorFactory.createSchemaGenerator(dataSchema);
ProtocolSchema protocol = schemaGenerator.getProtocolSchema(); ProtocolSchema protocol = schemaGenerator.getProtocolSchema();
Expand Down
Expand Up @@ -67,8 +67,6 @@
import org.kaaproject.kaa.common.dto.TopicTypeDto; import org.kaaproject.kaa.common.dto.TopicTypeDto;
import org.kaaproject.kaa.common.dto.UpdateNotificationDto; import org.kaaproject.kaa.common.dto.UpdateNotificationDto;
import org.kaaproject.kaa.common.dto.UserDto; import org.kaaproject.kaa.common.dto.UserDto;
import org.kaaproject.kaa.common.dto.credentials.CredentialsDto;
import org.kaaproject.kaa.common.dto.credentials.CredentialsStatus;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaDto; import org.kaaproject.kaa.common.dto.ctl.CTLSchemaDto;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaMetaInfoDto; import org.kaaproject.kaa.common.dto.ctl.CTLSchemaMetaInfoDto;
import org.kaaproject.kaa.common.dto.logs.LogAppenderDto; import org.kaaproject.kaa.common.dto.logs.LogAppenderDto;
Expand All @@ -82,7 +80,6 @@
import org.kaaproject.kaa.server.common.core.schema.KaaSchema; import org.kaaproject.kaa.server.common.core.schema.KaaSchema;
import org.kaaproject.kaa.server.common.core.schema.KaaSchemaFactoryImpl; import org.kaaproject.kaa.server.common.core.schema.KaaSchemaFactoryImpl;
import org.kaaproject.kaa.server.common.core.schema.OverrideSchema; import org.kaaproject.kaa.server.common.core.schema.OverrideSchema;
import org.kaaproject.kaa.server.common.dao.exception.CredentialsServiceException;
import org.kaaproject.kaa.server.common.dao.impl.LogAppenderDao; import org.kaaproject.kaa.server.common.dao.impl.LogAppenderDao;
import org.kaaproject.kaa.server.common.dao.impl.TenantDao; import org.kaaproject.kaa.server.common.dao.impl.TenantDao;
import org.kaaproject.kaa.server.common.dao.impl.UserDao; import org.kaaproject.kaa.server.common.dao.impl.UserDao;
Expand Down Expand Up @@ -223,7 +220,7 @@ public class AbstractTest {
@Autowired @Autowired
protected SdkProfileDao<SdkProfile> sdkProfileDao; protected SdkProfileDao<SdkProfile> sdkProfileDao;
@Autowired @Autowired
protected CTLSchemaDao<CTLSchema> ctlSchemaDao; protected CTLSchemaDao<CTLSchema> ctlSchemaDao;
@Autowired @Autowired
protected CTLSchemaMetaInfoDao<CTLSchemaMetaInfo> ctlSchemaMetaInfoDao; protected CTLSchemaMetaInfoDao<CTLSchemaMetaInfo> ctlSchemaMetaInfoDao;
@Autowired @Autowired
Expand All @@ -247,7 +244,7 @@ protected void clearDBData() {
if (url.contains("h2")) { if (url.contains("h2")) {
LOG.info("Deleting data from H2 database"); LOG.info("Deleting data from H2 database");
new H2DBTestRunner().truncateTables(dataSource); new H2DBTestRunner().truncateTables(dataSource);
} else if(url.contains("postgres")) { } else if (url.contains("postgres")) {
LOG.info("Deleting data from PostgreSQL database"); LOG.info("Deleting data from PostgreSQL database");
new PostgreDBTestRunner().truncateTables(dataSource); new PostgreDBTestRunner().truncateTables(dataSource);
} else { } else {
Expand Down Expand Up @@ -286,7 +283,7 @@ protected String readSchemaFileAsString(String filePath) throws IOException {
protected ApplicationDto generateApplicationDto() { protected ApplicationDto generateApplicationDto() {
return generateApplicationDto(null); return generateApplicationDto(null);
} }

protected ApplicationDto generateApplicationDto(String tenantId) { protected ApplicationDto generateApplicationDto(String tenantId) {
return generateApplicationDto(tenantId, null); return generateApplicationDto(tenantId, null);
} }
Expand Down Expand Up @@ -321,33 +318,39 @@ protected EndpointGroupDto generateEndpointGroupDto(String appId, String endpoin
return endpointService.saveEndpointGroup(group); return endpointService.saveEndpointGroup(group);
} }


protected List<ConfigurationSchemaDto> generateConfSchemaDto(String appId, int count) { protected List<ConfigurationSchemaDto> generateConfSchemaDto(String tenantId, String appId, int count) {
return generateConfSchemaDto(appId, count, "dao/schema/testDataSchema.json");
}

protected List<ConfigurationSchemaDto> generateConfSchemaDto(String appId, int count, String path) {
List<ConfigurationSchemaDto> schemas = Collections.emptyList(); List<ConfigurationSchemaDto> schemas = Collections.emptyList();
try { try {
if (isBlank(tenantId)) {
tenantId = generateTenantDto().getId();
}
if (isBlank(appId)) { if (isBlank(appId)) {
appId = generateApplicationDto().getId(); appId = generateApplicationDto().getId();
} }

ConfigurationSchemaDto schemaDto; ConfigurationSchemaDto schemaDto;
CTLSchemaDto ctlSchemaDto = ctlService.saveCTLSchema(generateCTLSchemaDto(tenantId));
schemas = new ArrayList<>(count); schemas = new ArrayList<>(count);

for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
schemaDto = new ConfigurationSchemaDto(); schemaDto = new ConfigurationSchemaDto();
schemaDto.setApplicationId(appId); schemaDto.setApplicationId(appId);
schemaDto.setSchema(readSchemaFileAsString(path)); schemaDto.setCtlSchemaId(ctlSchemaDto.getId());
schemaDto.setCreatedUsername("Test User");
schemaDto.setName("Test Name");
schemaDto = configurationService.saveConfSchema(schemaDto); schemaDto = configurationService.saveConfSchema(schemaDto);
Assert.assertNotNull(schemaDto); Assert.assertNotNull(schemaDto);
schemas.add(schemaDto); schemas.add(schemaDto);
} }

} catch (Exception e) { } catch (Exception e) {
LOG.error("Can't generate configs {}", e); LOG.error("Can't generate configs {}", e);
Assert.fail("Can't generate configuration schemas." + e.getMessage()); Assert.fail("Can't generate configuration schemas." + e.getMessage());
} }
return schemas; return schemas;
} }



protected List<ConfigurationDto> generateConfigurationDto(String schemaId, String groupId, int count, boolean activate, protected List<ConfigurationDto> generateConfigurationDto(String schemaId, String groupId, int count, boolean activate,
boolean useBaseSchema) { boolean useBaseSchema) {
List<ConfigurationDto> ids = Collections.emptyList(); List<ConfigurationDto> ids = Collections.emptyList();
Expand All @@ -356,7 +359,7 @@ protected List<ConfigurationDto> generateConfigurationDto(String schemaId, Strin
if (isNotBlank(schemaId)) { if (isNotBlank(schemaId)) {
schemaDto = configurationService.findConfSchemaById(schemaId); schemaDto = configurationService.findConfSchemaById(schemaId);
} else { } else {
schemaDto = generateConfSchemaDto(null, 1).get(0); schemaDto = generateConfSchemaDto(null, null, 1).get(0);
} }
Assert.assertNotNull(schemaDto); Assert.assertNotNull(schemaDto);
KaaSchema kaaSchema = useBaseSchema ? new BaseSchema(schemaDto.getBaseSchema()) : new OverrideSchema( KaaSchema kaaSchema = useBaseSchema ? new BaseSchema(schemaDto.getBaseSchema()) : new OverrideSchema(
Expand Down Expand Up @@ -711,7 +714,7 @@ protected EndpointUserConfigurationDto generateEndpointUserConfigurationDto(Endp
configurationDto.setUserId(endpointUser.getId()); configurationDto.setUserId(endpointUser.getId());


if (configurationSchema == null) { if (configurationSchema == null) {
configurationSchema = generateConfSchemaDto(applicationDto.getId(), 1).get(0); configurationSchema = generateConfSchemaDto(null, applicationDto.getId(), 1).get(0);
} }
configurationDto.setSchemaVersion(configurationSchema.getVersion()); configurationDto.setSchemaVersion(configurationSchema.getVersion());


Expand Down Expand Up @@ -787,7 +790,7 @@ protected CTLSchemaDto generateCTLSchemaDto(String fqn, String tenantId, String
ctlSchema.setBody(body.toString()); ctlSchema.setBody(body.toString());
return ctlSchema; return ctlSchema;
} }

protected String ctlRandomFqn() { protected String ctlRandomFqn() {
return DEFAULT_FQN + RANDOM.nextInt(100000); return DEFAULT_FQN + RANDOM.nextInt(100000);
} }
Expand All @@ -798,14 +801,14 @@ protected ServerProfileSchemaDto generateServerProfileSchema(String appId, Strin


protected ServerProfileSchemaDto generateServerProfileSchema(String appId, String tenantId, int version) { protected ServerProfileSchemaDto generateServerProfileSchema(String appId, String tenantId, int version) {
ServerProfileSchemaDto schemaDto = new ServerProfileSchemaDto(); ServerProfileSchemaDto schemaDto = new ServerProfileSchemaDto();
if(isBlank(tenantId)) { if (isBlank(tenantId)) {
ApplicationDto applicationDto = generateApplicationDto(); ApplicationDto applicationDto = generateApplicationDto();
appId = applicationDto.getId(); appId = applicationDto.getId();
tenantId = applicationDto.getTenantId(); tenantId = applicationDto.getTenantId();
} }
schemaDto.setApplicationId(appId); schemaDto.setApplicationId(appId);
schemaDto.setCreatedTime(System.currentTimeMillis()); schemaDto.setCreatedTime(System.currentTimeMillis());

CTLSchemaDto ctlSchema = ctlService.saveCTLSchema(generateCTLSchemaDto(ctlRandomFqn(), tenantId, appId, version)); CTLSchemaDto ctlSchema = ctlService.saveCTLSchema(generateCTLSchemaDto(ctlRandomFqn(), tenantId, appId, version));
schemaDto.setCtlSchemaId(ctlSchema.getId()); schemaDto.setCtlSchemaId(ctlSchema.getId());
return serverProfileService.saveServerProfileSchema(schemaDto); return serverProfileService.saveServerProfileSchema(schemaDto);
Expand Down
Expand Up @@ -160,18 +160,21 @@ protected List<ConfigurationSchema> generateConfSchema(Application app, int coun
if (app == null) { if (app == null) {
app = generateApplication(null); app = generateApplication(null);
} }
CTLSchema ctlSchema = generateCTLSchema(DEFAULT_FQN, 1, app.getTenant(), null);
ConfigurationSchema schema; ConfigurationSchema schema;
schemas = new ArrayList<>(count); schemas = new ArrayList<>(count);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
schema = new ConfigurationSchema(); schema = new ConfigurationSchema();
schema.setApplication(app); schema.setApplication(app);
schema.setSchema(readSchemaFileAsString("dao/schema/testDataSchema.json")); schema.setCreatedUsername("Test User");
schema.setCtlSchema(ctlSchema);
schema.setVersion(i + 1); schema.setVersion(i + 1);
schema.setName("Test Name");
schema = configurationSchemaDao.save(schema); schema = configurationSchemaDao.save(schema);
Assert.assertNotNull(schema); Assert.assertNotNull(schema);
schemas.add(schema); schemas.add(schema);
} }
} catch (IOException e) { } catch (Exception e) {
LOG.error("Can't generate configuration schemas {}", e); LOG.error("Can't generate configuration schemas {}", e);
Assert.fail("Can't generate configuration schemas." + e.getMessage()); Assert.fail("Can't generate configuration schemas." + e.getMessage());
} }
Expand Down
Expand Up @@ -139,7 +139,7 @@ public void editConfigurationObjectTest() {


@Test @Test
public void findConfSchemaByIdTest() { public void findConfSchemaByIdTest() {
List<ConfigurationSchemaDto> schemas = generateConfSchemaDto(null, 1); List<ConfigurationSchemaDto> schemas = generateConfSchemaDto(null, null, 1);
ConfigurationSchemaDto schema = schemas.get(0); ConfigurationSchemaDto schema = schemas.get(0);
ConfigurationSchemaDto foundSchema = configurationService.findConfSchemaById(schema.getId()); ConfigurationSchemaDto foundSchema = configurationService.findConfSchemaById(schema.getId());
Assert.assertNotNull(foundSchema); Assert.assertNotNull(foundSchema);
Expand Down Expand Up @@ -222,13 +222,14 @@ public void findConfSchemaByAppIdAndVersionTest() {


@Test @Test
public void saveConfSchemaTest() throws SchemaCreationException, IOException { public void saveConfSchemaTest() throws SchemaCreationException, IOException {
String id = generateConfSchemaDto(null, 1).get(0).getId(); String id = generateConfSchemaDto(null, null, 1).get(0).getId();
ConfigurationSchemaDto schema = configurationService.findConfSchemaById(id); ConfigurationSchemaDto schema = configurationService.findConfSchemaById(id);
Assert.assertNotNull(schema); Assert.assertNotNull(schema);
int version = schema.getVersion();
schema.setId(null); schema.setId(null);
schema.setSchema(new DataSchema(readSchemaFileAsString("dao/configuration/default_schema.json")).getRawSchema());
ConfigurationSchemaDto saved = configurationService.saveConfSchema(schema); ConfigurationSchemaDto saved = configurationService.saveConfSchema(schema);
Assert.assertNotNull(saved); Assert.assertNotNull(saved);
Assert.assertNotEquals(version, saved.getVersion());
Assert.assertNotEquals(schema.getId(), saved.getId()); Assert.assertNotEquals(schema.getId(), saved.getId());
} }


Expand Down Expand Up @@ -272,14 +273,14 @@ public void createSchemaTest() throws Exception {
@Test @Test
public void createDefaultSchemaTest() { public void createDefaultSchemaTest() {
String id = generateApplicationDto().getId(); String id = generateApplicationDto().getId();
ConfigurationSchemaDto schema = generateConfSchemaDto(id, 1).get(0); ConfigurationSchemaDto schema = generateConfSchemaDto(null, id, 1).get(0);
ConfigurationDto config = configurationService.findConfigurationByAppIdAndVersion(id, schema.getVersion()); ConfigurationDto config = configurationService.findConfigurationByAppIdAndVersion(id, schema.getVersion());
Assert.assertEquals(config.getStatus(), UpdateStatus.ACTIVE); Assert.assertEquals(config.getStatus(), UpdateStatus.ACTIVE);
} }


@Test @Test
public void findDefaultConfigurationBySchemaIdTest() { public void findDefaultConfigurationBySchemaIdTest() {
ConfigurationSchemaDto schema = generateConfSchemaDto(null, 1).get(0); ConfigurationSchemaDto schema = generateConfSchemaDto(null, null, 1).get(0);
ConfigurationDto configuration = configurationService.findDefaultConfigurationBySchemaId(schema.getId()); ConfigurationDto configuration = configurationService.findDefaultConfigurationBySchemaId(schema.getId());
Assert.assertNotNull(configuration); Assert.assertNotNull(configuration);
Assert.assertEquals(UpdateStatus.ACTIVE, configuration.getStatus()); Assert.assertEquals(UpdateStatus.ACTIVE, configuration.getStatus());
Expand All @@ -288,7 +289,7 @@ public void findDefaultConfigurationBySchemaIdTest() {


@Test @Test
public void findConfigurationByEndpointGroupIdAndVersionTest() { public void findConfigurationByEndpointGroupIdAndVersionTest() {
ConfigurationSchemaDto schema = generateConfSchemaDto(null, 1).get(0); ConfigurationSchemaDto schema = generateConfSchemaDto(null, null, 1).get(0);
String groupId = generateEndpointGroupDto(schema.getApplicationId()).getId(); String groupId = generateEndpointGroupDto(schema.getApplicationId()).getId();
ConfigurationDto config = generateConfigurationDto(schema.getId(), groupId, 1, true, false).get(0); ConfigurationDto config = generateConfigurationDto(schema.getId(), groupId, 1, true, false).get(0);
ConfigurationDto configuration = configurationService.findConfigurationByEndpointGroupIdAndVersion(groupId, schema.getVersion()); ConfigurationDto configuration = configurationService.findConfigurationByEndpointGroupIdAndVersion(groupId, schema.getVersion());
Expand Down Expand Up @@ -318,7 +319,7 @@ public void deactivateConfigurationTest() {


@Test @Test
public void deleteConfigurationRecordTest() { public void deleteConfigurationRecordTest() {
ConfigurationSchemaDto schemaDto = generateConfSchemaDto(null, 1).get(0); ConfigurationSchemaDto schemaDto = generateConfSchemaDto(null, null, 1).get(0);
EndpointGroupDto group = generateEndpointGroupDto(schemaDto.getApplicationId()); EndpointGroupDto group = generateEndpointGroupDto(schemaDto.getApplicationId());
generateConfigurationDto(schemaDto.getId(), group.getId(), 1, true, false); generateConfigurationDto(schemaDto.getId(), group.getId(), 1, true, false);
ChangeConfigurationNotification notification = configurationService.deleteConfigurationRecord(schemaDto.getId(), group.getId(), ChangeConfigurationNotification notification = configurationService.deleteConfigurationRecord(schemaDto.getId(), group.getId(),
Expand All @@ -335,7 +336,7 @@ public void deleteConfigurationRecordTest() {
@Test @Test
public void findAllConfigurationRecordsByEndpointGroupIdTest() { public void findAllConfigurationRecordsByEndpointGroupIdTest() {
String id = generateApplicationDto().getId(); String id = generateApplicationDto().getId();
ConfigurationSchemaDto schema = generateConfSchemaDto(id, 1).get(0); ConfigurationSchemaDto schema = generateConfSchemaDto(null, id, 1).get(0);
EndpointGroupDto group = generateEndpointGroupDto(id); EndpointGroupDto group = generateEndpointGroupDto(id);
generateConfigurationDto(schema.getId(), group.getId(), 1, true, false); generateConfigurationDto(schema.getId(), group.getId(), 1, true, false);
List<ConfigurationRecordDto> records = (List<ConfigurationRecordDto>) configurationService List<ConfigurationRecordDto> records = (List<ConfigurationRecordDto>) configurationService
Expand All @@ -350,7 +351,7 @@ public void findAllConfigurationRecordsByEndpointGroupIdTest() {


@Test @Test
public void findConfigurationRecordBySchemaIdAndEndpointGroupIdTest() { public void findConfigurationRecordBySchemaIdAndEndpointGroupIdTest() {
ConfigurationSchemaDto schema = generateConfSchemaDto(null, 1).get(0); ConfigurationSchemaDto schema = generateConfSchemaDto(null, null, 1).get(0);
EndpointGroupDto group = generateEndpointGroupDto(schema.getApplicationId()); EndpointGroupDto group = generateEndpointGroupDto(schema.getApplicationId());
ConfigurationDto activeConfig = generateConfigurationDto(schema.getId(), group.getId(), 1, true, false).get(0); ConfigurationDto activeConfig = generateConfigurationDto(schema.getId(), group.getId(), 1, true, false).get(0);
ConfigurationDto inactiveConfig = generateConfigurationDto(schema.getId(), group.getId(), 1, false, false).get(0); ConfigurationDto inactiveConfig = generateConfigurationDto(schema.getId(), group.getId(), 1, false, false).get(0);
Expand All @@ -363,7 +364,7 @@ public void findConfigurationRecordBySchemaIdAndEndpointGroupIdTest() {
@Test @Test
public void findVacantSchemasByEndpointGroupIdTest() { public void findVacantSchemasByEndpointGroupIdTest() {
ApplicationDto application = generateApplicationDto(); ApplicationDto application = generateApplicationDto();
List<ConfigurationSchemaDto> schemas = generateConfSchemaDto(application.getId(), 4); List<ConfigurationSchemaDto> schemas = generateConfSchemaDto(null, application.getId(), 4);
EndpointGroupDto groupOne = generateEndpointGroupDto(application.getId()); EndpointGroupDto groupOne = generateEndpointGroupDto(application.getId());
ConfigurationSchemaDto schemaOne = schemas.get(0); ConfigurationSchemaDto schemaOne = schemas.get(0);
generateConfigurationDto(schemaOne.getId(), groupOne.getId(), 1, true, false); generateConfigurationDto(schemaOne.getId(), groupOne.getId(), 1, true, false);
Expand All @@ -380,7 +381,7 @@ public void findVacantSchemasByEndpointGroupIdTest() {


@Test @Test
public void findConfigurationSchemaVersionsByAppIdTest() { public void findConfigurationSchemaVersionsByAppIdTest() {
ConfigurationSchemaDto schemaDto = generateConfSchemaDto(null, 1).get(0); ConfigurationSchemaDto schemaDto = generateConfSchemaDto(null, null, 1).get(0);
List<VersionDto> versions = configurationService.findConfigurationSchemaVersionsByAppId(schemaDto.getApplicationId()); List<VersionDto> versions = configurationService.findConfigurationSchemaVersionsByAppId(schemaDto.getApplicationId());
Assert.assertFalse(versions.isEmpty()); Assert.assertFalse(versions.isEmpty());
Assert.assertEquals(2, versions.size()); Assert.assertEquals(2, versions.size());
Expand Down

0 comments on commit 0300d0b

Please sign in to comment.