/** * Get id of application. * * @return id, return null if application hasn't id */ public String getApplicationId() { Long id = null; if (application != null) { id = application.getId(); } return id != null ? String.valueOf(id) : null; }
/** * Return application id. */ public String getApplicationId() { Long id = null; if (application != null) { id = application.getId(); } return id != null ? String.valueOf(id) : null; }
@Test public void testFindVacantSchemasTest() { Application app1 = generateApplication(null); List<ConfigurationSchema> schemas1 = generateConfSchema(app1, 3); List<String> ids1 = new ArrayList<>(2); ids1.add(schemas1.get(0).getId().toString()); List<ConfigurationSchema> found2 = configurationSchemaDao.findVacantSchemas(app1.getId().toString(), ids1); Assert.assertEquals(2, found2.size()); List<ConfigurationSchema> found3 = configurationSchemaDao.findVacantSchemas(app1.getId().toString(), null); Assert.assertEquals(3, found3.size()); } }
@Test public void findBySeqNumberStartTest() { List<History> histories = generateHistory(null, 3); Assert.assertNotNull(histories); History third = histories.get(2); List<History> found = historyDao.findBySeqNumberStart(third.getApplication().getId().toString(), 2); Assert.assertEquals(1, found.size()); Assert.assertEquals(third, found.get(0)); }
@Test public void findByAppIdTest() { UserVerifier verifier = generateUserVerifier(null, null); Application app = verifier.getApplication(); List<UserVerifier> result = verifierDao.findByAppId(app.getId().toString()); Assert.assertEquals(result.size(), 1); }
@Test public void findByApplicationId() { List<EndpointProfileSchema> schemas = generateProfSchema(null, 3); Assert.assertEquals(3, schemas.size()); EndpointProfileSchema schema = schemas.get(0); Application app = schema.getApplication(); List<EndpointProfileSchema> found = profileSchemaDao.findByApplicationId(app.getId().toString()); Assert.assertEquals(3, found.size()); Assert.assertEquals(schemas, found); }
@Test public void testFindTopicsByAppIdAndType() { Topic topic = generateTopic(null, TopicTypeDto.OPTIONAL, null); Application app = topic.getApplication(); List<Topic> found = topicDao.findTopicsByAppIdAndType(app.getId().toString(), TopicTypeDto.OPTIONAL); Assert.assertEquals(1, found.size()); Assert.assertEquals(topic, found.get(0)); }
@Test public void findSdkProfilesByApplicationIdTest() { SdkProfile saved = this.generateSdkProfile(null, null); List<SdkProfile> loaded = sdkProfileDao.findSdkProfileByApplicationId(saved.getApplication().getId().toString()); Assert.assertEquals(1, loaded.size()); Assert.assertEquals(saved, loaded.get(0)); } }
@Test public void testFindTopicsByAppId() { Topic topic = generateTopic(null, null, null); Application app = topic.getApplication(); List<Topic> found = topicDao.findTopicsByAppId(app.getId().toString()); Assert.assertEquals(1, found.size()); Assert.assertEquals(topic, found.get(0)); }
@Test public void testSaveApplication() { Application application = generateApplication(null); Assert.assertNotNull(application.getId()); }
@Test public void findBySeqNumberTest() { List<History> histories = generateHistory(null, 3); Assert.assertNotNull(histories); History third = histories.get(2); History found = historyDao.findBySeqNumber(third.getApplication().getId().toString(), 3); Assert.assertEquals(third, found); }
@Test public void findEndpointGroupsByTopicIdAndAppId() throws InterruptedException { Topic topic = generateTopic(null, null, null); Set<Topic> topics = new HashSet<>(); topics.add(topic); EndpointGroup endpointGroup = generateEndpointGroup(topic.getApplication(), topics); List<EndpointGroup> found = endpointGroupDao.findEndpointGroupsByTopicIdAndAppId(topic.getApplication().getId().toString(), topic.getId().toString()); Assert.assertNotNull(found); Assert.assertEquals(1, found.size()); Assert.assertEquals(endpointGroup, found.get(0)); }
@Test public void findByAppIdTest() { List<History> histories = generateHistory(null, 3); Assert.assertNotNull(histories); History first = histories.get(0); List<History> found = historyDao.findByAppId(first.getApplication().getId().toString()); Assert.assertEquals(histories, found); }
@Test public void findLatestByApplicationIdTest() { List<ConfigurationSchema> schemas = generateConfSchema(null, 4); Assert.assertEquals(4, schemas.size()); ConfigurationSchema schema = schemas.get(0); Application app = schema.getApplication(); ConfigurationSchema found = configurationSchemaDao.findLatestByApplicationId(app.getId().toString()); Assert.assertNotNull(found); Assert.assertEquals(4, found.getVersion()); }
@Test public void findLatestByAppId() { List<EndpointProfileSchema> schemas = generateProfSchema(null, 4); Assert.assertEquals(4, schemas.size()); EndpointProfileSchema schema = schemas.get(0); Application app = schema.getApplication(); EndpointProfileSchema found = profileSchemaDao.findLatestByAppId(app.getId().toString()); Assert.assertNotNull(found); Assert.assertEquals(4, found.getVersion()); }
@Test public void testRemoveTopicsByAppId() { Topic topic = generateTopic(null, null, null); Application app = topic.getApplication(); topicDao.removeTopicsByAppId(app.getId().toString()); Topic found = topicDao.findById(topic.getId().toString()); Assert.assertNull(found); }
@Test public void findByAppIdAndVersionTest() { List<ConfigurationSchema> schemas = generateConfSchema(null, 4); Assert.assertEquals(4, schemas.size()); ConfigurationSchema schema = schemas.get(2); Application app = schema.getApplication(); ConfigurationSchema found = configurationSchemaDao.findByAppIdAndVersion(app.getId().toString(), schema.getVersion()); Assert.assertNotNull(found); Assert.assertEquals(3, found.getVersion()); }
@Test public void findByAppIdAndVersion() { List<EndpointProfileSchema> schemas = generateProfSchema(null, 4); Assert.assertEquals(4, schemas.size()); EndpointProfileSchema schema = schemas.get(2); Application app = schema.getApplication(); EndpointProfileSchema found = profileSchemaDao.findByAppIdAndVersion(app.getId().toString(), schema.getVersion()); Assert.assertNotNull(found); Assert.assertEquals(3, found.getVersion()); }
@Test public void testValidateApplicationEventFamilyMap() { List<ApplicationEventFamilyMap> applicationEventFamilyMaps = generateApplicationEventFamilyMap(null, null, null, 2, true); ApplicationEventFamilyMap aefm = applicationEventFamilyMaps.get(0); boolean result = applicationEventFamilyMapDao.validateApplicationEventFamilyMap(aefm.getApplication().getId().toString(), aefm.getEcf().getId() .toString(), aefm.getVersion()); Assert.assertFalse(result); result = applicationEventFamilyMapDao.validateApplicationEventFamilyMap("7", "7", 7); Assert.assertTrue(result); }
@Test public void testGetNextSeqNumber() { Tenant ten = generateTenant(); Application app = generateApplication(ten); int sequenceNumber = app.getSequenceNumber(); app = applicationDao.getNextSeqNumber(app.getId().toString()); Assert.assertNotEquals(sequenceNumber, app.getSequenceNumber()); }