@Override public LogAppenderDto toDto() { LogAppenderDto dto = super.toDto(); dto.setId(getStringId()); if (application != null) { dto.setApplicationToken(application.getApplicationToken()); dto.setTenantId(application.getTenant().getStringId()); } dto.setMinLogSchemaVersion(minLogSchemaVersion); dto.setMaxLogSchemaVersion(maxLogSchemaVersion); dto.setConfirmDelivery(confirmDelivery); dto.setHeaderStructure(headerStructure != null ? new ArrayList<>(headerStructure) : new ArrayList<>()); return dto; }
protected List<ConfigurationSchema> generateConfSchema(Application app, int count) { List<ConfigurationSchema> schemas = Collections.emptyList(); try { if (app == null) { app = generateApplication(null); } CtlSchema ctlSchema = generateCTLSchema(DEFAULT_FQN, 1, app.getTenant(), null); ConfigurationSchema schema; schemas = new ArrayList<>(count); for (int i = 0; i < count; i++) { schema = new ConfigurationSchema(); schema.setApplication(app); schema.setCreatedUsername("Test User"); schema.setCtlSchema(ctlSchema); schema.setVersion(i + 1); schema.setName("Test Name"); schema = configurationSchemaDao.save(schema); Assert.assertNotNull(schema); schemas.add(schema); } } catch (Exception ex) { LOG.error("Can't generate configuration schemas {}", ex); Assert.fail("Can't generate configuration schemas." + ex.getMessage()); } return schemas; }
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; }
protected List<LogSchema> generateLogSchema(Tenant tenant, int ctlVersion, Application application, int count) { List<LogSchema> schemas = Collections.emptyList(); try { if (application == null) { application = generateApplication(tenant); } CtlSchema ctlSchema = generateCTLSchema(DEFAULT_FQN, ctlVersion, application.getTenant(), null); LogSchema schema; schemas = new ArrayList<>(count); for (int i = 0; i < count; i++) { schema = new LogSchema(); schema.setApplication(application); schema.setCtlSchema(ctlSchema); schema.setCreatedUsername("Test User"); schema.setName("Test Name"); schema = logSchemaDao.save(schema); Assert.assertNotNull(schema); schemas.add(schema); } } catch (Exception ex) { LOG.error("Can't generate log schemas {}", ex); Assert.fail("Can't generate log schemas."); } return schemas; }
protected List<NotificationSchema> generateNotificationSchema(Application app, int ctlVersion, int count, NotificationTypeDto type) { List<NotificationSchema> schemas = Collections.emptyList(); try { if (app == null) { app = generateApplication(null); } CtlSchema ctlSchema = generateCTLSchema(DEFAULT_FQN, ctlVersion, app.getTenant(), null); NotificationSchema schemaDto; schemas = new ArrayList<>(count); for (int i = 0; i < count; i++) { schemaDto = new NotificationSchema(); schemaDto.setApplication(app); schemaDto.setCreatedUsername("Test User"); schemaDto.setCtlSchema(ctlSchema); schemaDto.setVersion(i + 1); schemaDto.setName("Test Name"); schemaDto.setType(type); schemaDto = notificationSchemaDao.save(schemaDto); Assert.assertNotNull(schemaDto); schemas.add(schemaDto); } } catch (Exception ex) { LOG.error("Can't generate profile schema {}", ex); Assert.fail("Can't generate profile schema." + ex.getMessage()); } return schemas; }
@Test public void findByAppIdAndSchemaVersion() { Application app = generateApplication(null); EndpointProfileSchema schema = generateProfSchema(app, 1).get(0); ServerProfileSchemaDto srvSchema = generateServerProfileSchema(app.getStringId(), app.getTenant().getStringId(), 101); generateFilter(schema, new ServerProfileSchema(srvSchema), null, 2, UpdateStatus.ACTIVE); List<ProfileFilter> filters = generateFilterWithoutSchemaGeneration(schema, new ServerProfileSchema(srvSchema), null, 1, UpdateStatus.ACTIVE); filters.addAll(generateFilterWithoutSchemaGeneration(null, new ServerProfileSchema(srvSchema), null, 1, UpdateStatus.ACTIVE)); filters.addAll(generateFilterWithoutSchemaGeneration(schema, null, null, 1, UpdateStatus.ACTIVE)); List<ProfileFilter> found = profileFilterDao.findByAppIdAndSchemaVersionsCombination(app.getStringId(), schema.getVersion(), srvSchema.getVersion()); Assert.assertEquals(filters, found); }
protected List<ProfileFilter> generateFilter(Application app, EndpointProfileSchema schema, ServerProfileSchema srvSchema, EndpointGroup group, int count, UpdateStatus status) { if (schema == null) { schema = generateProfSchema(app, 1).get(0); } if (srvSchema == null) { srvSchema = new ServerProfileSchema(generateServerProfileSchema(app.getStringId(), app.getTenant().getStringId())); } if (group == null) { group = generateEndpointGroup(app, null); } List<ProfileFilter> filters = new ArrayList<>(); for (int i = 0; i < count; i++) { ProfileFilter dto = new ProfileFilter(); dto.setId(null); dto.setStatus(status != null ? status : UpdateStatus.INACTIVE); dto.setEndpointGroup(group); dto.setEndpointProfileSchema(schema); dto.setServerProfileSchema(srvSchema); dto.setSequenceNumber(i); dto.setApplication(app); ProfileFilter saved = profileFilterDao.save(dto); Assert.assertNotNull(saved); filters.add(saved); } return filters; }