@Override protected GenericModel<EndpointProfileSchemaDto> newInstance(Long id) { return new EndpointProfileSchema(id); } }
/** * Create new instance of <code>ProfileFilter</code>. * @param dto data transfer object contain body, * endpoint profile schema id, server profile * schema id. Assign these values on corresponding * fields of new instance */ public ProfileFilter(ProfileFilterDto dto) { super(dto); this.body = dto.getBody(); String endpointSchemaId = dto.getEndpointProfileSchemaId(); if (isNotBlank(endpointSchemaId)) { this.endpointProfileSchema = new EndpointProfileSchema(getLongId(endpointSchemaId)); } String serverSchemaId = dto.getServerProfileSchemaId(); if (isNotBlank(serverSchemaId)) { this.serverProfileSchema = new ServerProfileSchema(getLongId(serverSchemaId)); } }
oldProfileSchemaDto.editFields(profileSchemaDto); profileSchemaDto = oldProfileSchemaDto; return getDto(profileSchemaDao.save(new EndpointProfileSchema(profileSchemaDto))); } else { LOG.error("Can't find profile schema with given id [{}].", id); return getDto(profileSchemaDao.save(new EndpointProfileSchema(profileSchemaDto))); } else { throw new IncorrectParameterException("Invalid profile schema object. "
protected List<EndpointProfileSchema> generateProfSchema(Application app, int count) { List<EndpointProfileSchema> schemas = Collections.emptyList(); try { if (app == null) { app = generateApplication(null); } CtlSchema ctlSchema = generateCTLSchema(DEFAULT_FQN, 1, app.getTenant(), null); EndpointProfileSchema schemaDto; schemas = new ArrayList<>(count); for (int i = 0; i < count; i++) { schemaDto = new EndpointProfileSchema(); schemaDto.setApplication(app); schemaDto.setCreatedUsername("Test User"); schemaDto.setCtlSchema(ctlSchema); schemaDto.setVersion(i + 1); schemaDto.setName("Test Name"); schemaDto = profileSchemaDao.save(schemaDto); Assert.assertNotNull(schemaDto); schemas.add(schemaDto); } } catch (Exception e) { LOG.error("Can't generate profile schema {}", e); Assert.fail("Can't generate profile schema." + e.getMessage()); } return schemas; }
@Test public void updateExistingProfileSchemaTest() { ApplicationDto app = generateApplicationDto(null); String appId = app.getId(); List<EndpointProfileSchemaDto> schemas = generateProfSchemaDto(app.getTenantId(), appId, 1); EndpointProfileSchemaDto schema = profileService.findProfileSchemaById(schemas.get(0).getId()); Assert.assertNotNull(schema); EndpointProfileSchema endpointProfileSchema = new EndpointProfileSchema(schema); endpointProfileSchema.setName("Updated name"); endpointProfileSchema.setDescription("Updated description"); EndpointProfileSchemaDto saved = profileService.saveProfileSchema(endpointProfileSchema.toDto()); Assert.assertNotNull(saved); Assert.assertEquals(schema.getId(), saved.getId()); Assert.assertEquals(schema.getApplicationId(), saved.getApplicationId()); Assert.assertNotEquals(schema.getName(), saved.getName()); Assert.assertNotEquals(schema.getDescription(), saved.getDescription()); }