private ConfigurationDto toConfigurationDto(ConfigurationRecordFormDto configuration) throws KaaAdminServiceException, IOException { String body = null; RecordField configurationRecord = configuration.getConfigurationRecord(); if (configurationRecord != null) { GenericRecord record = FormAvroConverter.createGenericRecordFromRecordField( configurationRecord); GenericAvroConverter<GenericRecord> converter = new GenericAvroConverter<>( record.getSchema()); body = converter.encodeToJson(record); } ConfigurationDto result = new ConfigurationDto(configuration); result.setBody(body); return result; }
@Override public ConfigurationDto toDto() { ConfigurationDto dto = super.toDto(); dto.setBody(binaryToString(configurationBody)); dto.setSchemaId(ModelUtils.getStringId(configurationSchema.getId())); dto.setSchemaVersion(schemaVersion); dto.setProtocolSchema(configurationSchema != null ? configurationSchema.getProtocolSchema() : null); return dto; }
currentConfiguration.setBody(body.getRawData()); } else { throw new RuntimeException("Can't generate json configuration body."); // NOSONAR
LOG.debug("Default configuration {} ", body.getRawData()); ConfigurationDto configurationDto = new ConfigurationDto(); configurationDto.setBody(body.getRawData()); configurationDto.setSchemaId(savedSchema.getId()); configurationDto.setDescription(DEFAULT_STRUCT_DESC);
dto.setId(null); dto.setStatus(null); dto.setBody(configurationProcessor.getRootData().getRawData()); dto.setSchemaId(schemaDto.getId()); if (isBlank(groupId)) {
@Test public void editConfigurationObjectTest() { List<ConfigurationDto> configs = generateConfigurationDto(null, null, 1, false, false); ConfigurationDto saved = configurationService.findConfigurationById(configs.get(0).getId()); ConfigurationDto configurationToEdit = new ConfigurationDto(); configurationToEdit.setId(saved.getId()); configurationToEdit.setApplicationId(saved.getApplicationId()); configurationToEdit.setEndpointGroupId(saved.getEndpointGroupId()); configurationToEdit.setSchemaId(saved.getSchemaId()); configurationToEdit.setVersion(saved.getVersion()); configurationToEdit.setBody(saved.getBody()); ConfigurationDto updated = configurationService.saveConfiguration(configurationToEdit); Assert.assertNotNull(saved); Assert.assertNotNull(updated); Assert.assertEquals(saved.getSchemaVersion(), updated.getSchemaVersion()); Assert.assertEquals(saved.getCreatedTime(), updated.getCreatedTime()); Assert.assertEquals(saved.getCreatedUsername(), updated.getCreatedUsername()); }