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()); }