@Test public void testCRUDApplicationEntity() throws SQLException, EntityNotFoundException { SiteEntity siteEntity = new SiteEntity(); siteEntity.setSiteId("testsiteid"); siteEntity.setSiteName("testsitename"); siteEntity.setDescription("testdesc"); siteEntityService.create(siteEntity); String siteuuid = siteEntity.getUuid(); long sitecreateTime = siteEntity.getCreatedTime(); long sitemodifiedTime = siteEntity.getModifiedTime(); ApplicationDesc applicationDesc = new ApplicationDesc(); applicationDesc.setType("testtype"); ApplicationEntity applicationEntity = new ApplicationEntity(); applicationEntity.setSite(siteEntity); applicationEntity.setDescriptor(applicationDesc); applicationEntity.setMode(ApplicationEntity.Mode.LOCAL); applicationEntity.setJarPath("c://"); applicationEntityService.create(applicationEntity); String appuuid = applicationEntity.getUuid(); String appId = applicationEntity.getAppId(); long createTime = applicationEntity.getCreatedTime(); long modifiedTime = applicationEntity.getModifiedTime(); Collection<ApplicationEntity> results = applicationEntityService.findAll(); Assert.assertEquals(1, results.size()); ApplicationEntity applicationEntityFromDB = applicationEntityService.getBySiteIdAndAppType("testsiteid", "testtype"); Assert.assertTrue(applicationEntityFromDB != null); results = applicationEntityService.findBySiteId("testsiteid"); Assert.assertEquals(1, results.size()); applicationEntityFromDB = applicationEntityService.getByUUID(appuuid); Assert.assertTrue(applicationEntityFromDB != null); applicationEntityFromDB = applicationEntityService.getByUUIDOrAppId(null, appId); Assert.assertEquals(siteuuid, applicationEntityFromDB.getSite().getUuid()); Assert.assertEquals("testsiteid", applicationEntityFromDB.getSite().getSiteId()); Assert.assertEquals("testsitename", applicationEntityFromDB.getSite().getSiteName()); Assert.assertEquals("testdesc", applicationEntityFromDB.getSite().getDescription()); Assert.assertEquals(sitecreateTime, applicationEntityFromDB.getSite().getCreatedTime()); Assert.assertEquals(sitemodifiedTime, applicationEntityFromDB.getSite().getModifiedTime()); Assert.assertEquals(appuuid, applicationEntityFromDB.getUuid()); Assert.assertEquals(appId, applicationEntityFromDB.getAppId()); Assert.assertEquals("testtype", applicationEntityFromDB.getDescriptor().getType()); Assert.assertEquals(ApplicationEntity.Mode.LOCAL, applicationEntityFromDB.getMode()); Assert.assertEquals("c://", applicationEntityFromDB.getJarPath()); Assert.assertEquals(ApplicationEntity.Status.INITIALIZED, applicationEntityFromDB.getStatus()); Assert.assertEquals(createTime, applicationEntityFromDB.getCreatedTime()); Assert.assertEquals(modifiedTime, applicationEntityFromDB.getModifiedTime()); }
@Test(expected = IllegalArgumentException.class) public void testInsertApplicationEntityFail() { SiteEntity siteEntity = new SiteEntity(); siteEntity.setSiteId("testsiteid"); siteEntity.setSiteName("testsitename"); siteEntity.setDescription("testdesc"); siteEntityService.create(siteEntity); ApplicationDesc applicationDesc = new ApplicationDesc(); applicationDesc.setType("testtype"); ApplicationEntity applicationEntity = new ApplicationEntity(); applicationEntity.setSite(siteEntity); applicationEntity.setDescriptor(applicationDesc); applicationEntity.setMode(ApplicationEntity.Mode.LOCAL); applicationEntity.setJarPath("c://"); applicationEntityService.create(applicationEntity); applicationEntityService.create(applicationEntity); }
@Test public void testDelApplicationEntity() { SiteEntity siteEntity = new SiteEntity(); siteEntity.setSiteId("testsiteid"); siteEntity.setSiteName("testsitename"); siteEntity.setDescription("testdesc"); siteEntityService.create(siteEntity); ApplicationDesc applicationDesc = new ApplicationDesc(); applicationDesc.setType("testtype"); ApplicationEntity applicationEntity = new ApplicationEntity(); applicationEntity.setSite(siteEntity); applicationEntity.setDescriptor(applicationDesc); applicationEntity.setMode(ApplicationEntity.Mode.LOCAL); applicationEntity.setJarPath("c://"); applicationEntityService.create(applicationEntity); Collection<ApplicationEntity> results = applicationEntityService.findAll(); Assert.assertEquals(1, results.size()); applicationEntityService.delete(applicationEntity); results = applicationEntityService.findAll(); Assert.assertEquals(0, results.size()); }