@Test public void testDuplicatePackageName() throws Exception { ModuleItem pack = getRepo().createModule( "dupePackageTest", "testing for dupe" ); assertNotNull(pack.getName()); try { getRepo().createModule( "dupePackageTest", "this should fail" ); fail("Should not be able to add a package of the same name."); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage()); } }
@Test public void testPackageInstanceWrongNodeType() throws Exception { ModuleItem pack = getRepo().loadDefaultModule(); AssetItem rule = pack.addAsset( "packageInstanceWrongNodeType", "" ); try { new ModuleItem(this.getRepo(), rule.getNode()); fail("Can't create a package from a rule node."); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage()); } }
@Test public void testFindRulesByCategory() throws Exception { getRepo().loadCategory( "/" ).addCategory( "testFindRulesByCat", "yeah" ); AssetItem as1 = getDefaultPackage().addAsset( "testFindRulesByCategory1", "ya", "testFindRulesByCat", "drl" ); getDefaultPackage().addAsset( "testFindRulesByCategory2", "ya", "testFindRulesByCat", AssetItem.DEFAULT_CONTENT_FORMAT ).checkin( "version0" ); as1.checkin( "version0" ); assertEquals("drl", as1.getFormat()); List rules = getRepo().findAssetsByCategory( "testFindRulesByCat", 0, -1 ).assets; assertEquals(2, rules.size()); for ( Iterator iter = rules.iterator(); iter.hasNext(); ) { AssetItem element = (AssetItem) iter.next(); assertTrue(element.getName().startsWith( "testFindRulesByCategory" )); } try { getRepo().loadCategory( "testFindRulesByCat" ).remove(); fail("should not be able to remove"); } catch (RulesRepositoryException e) { //assertTrue(e.getCause() instanceof ReferentialIntegrityException); assertNotNull(e.getMessage()); } }
fail("this should be rejected as its not archived."); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage());
@Test public void testAssetItemCreation() throws Exception { Calendar now = Calendar.getInstance(); Thread.sleep(500); //MN: need this sleep to get the correct date AssetItem ruleItem1 = getDefaultPackage().addAsset("testRuleItem", "test content"); assertNotNull(ruleItem1); assertNotNull(ruleItem1.getNode()); assertEquals("testRuleItem", ruleItem1.getName()); assertNotNull(ruleItem1.getCreatedDate()); assertTrue(now.before( ruleItem1.getCreatedDate() )); String packName = getDefaultPackage().getName(); assertEquals(packName, ruleItem1.getModuleName()); assertNotNull(ruleItem1.getUUID()); //try constructing with node of wrong type try { ModuleItem pitem = getRepo().loadDefaultModule(); new AssetItem(getRepo(), pitem.getNode()); fail("Exception not thrown for node of wrong type"); } catch(RulesRepositoryException e) { assertNotNull(e.getMessage()); } catch(Exception e) { fail("Caught unexpected exception: " + e); } }
@Test public void testLoadRulePackageItemByUUID() throws Exception { ModuleItem rulePackageItem = getRepo().createModule("testLoadRuleRuleItemByUUID", "desc"); String uuid = null; uuid = rulePackageItem.getNode().getUUID(); rulePackageItem = getRepo().loadModuleByUUID(uuid); assertNotNull(rulePackageItem); assertEquals("testLoadRuleRuleItemByUUID", rulePackageItem.getName()); // try loading rule package that was not created try { rulePackageItem = getRepo().loadModuleByUUID("01010101-0101-0101-0101-010101010101"); fail("Exception not thrown loading rule package that was not created."); } catch (RulesRepositoryException e) { // that is OK! assertNotNull(e.getMessage()); } }
assertNotNull( e.getMessage() );
@Test public void testLoadRulePackageItem() { ModuleItem rulePackageItem = getRepo().createModule("testLoadRuleRuleItem", "desc"); rulePackageItem = getRepo().loadModule("testLoadRuleRuleItem"); assertNotNull(rulePackageItem); assertEquals("testLoadRuleRuleItem", rulePackageItem.getName()); assertEquals("desc", rulePackageItem.getDescription()); assertEquals(ModuleItem.MODULE_FORMAT, rulePackageItem.getFormat()); // try loading rule package that was not created try { rulePackageItem = getRepo().loadModule("anotherRuleRuleItem"); fail("Exception not thrown loading rule package that was not created."); } catch (RulesRepositoryException e) { // that is OK! assertNotNull(e.getMessage()); } }
fail("should not be able to remove"); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage());
fail( "should not exist." ); } catch ( RulesRepositoryException e ) { assertNotNull( e.getMessage() );
@Test public void testSaveAndCheckinDescriptionAndTitle() throws Exception { AssetItem ruleItem1 = getRepo().loadDefaultModule().addAsset("testGetDescription", ""); ruleItem1.checkin( "version0" ); //it should be "" to begin with assertEquals("", ruleItem1.getDescription()); ruleItem1.updateDescription("test description"); assertEquals("test description", ruleItem1.getDescription()); assertTrue(getRepo().getSession().hasPendingChanges()); ruleItem1.updateTitle( "This is a title" ); assertTrue(getRepo().getSession().hasPendingChanges()); ruleItem1.checkin( "ya" ); //we can save without a checkin getRepo().getSession().save(); assertFalse(getRepo().getSession().hasPendingChanges()); try { ruleItem1.getPrecedingVersion().updateTitle( "baaad" ); fail("should not be able to do this"); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage()); } }
@Test public void testSaveAndCheckinDescriptionAndTitleForShareableAsset() throws Exception { AssetItem asset = getRepo().loadGlobalArea().addAsset("testSaveAndCheckinDescriptionAndTitleForShareableAsset", "desc"); asset.checkin("version0"); AssetItem linkedAsset = getDefaultPackage().addAssetImportedFromGlobalArea(asset.getName()); // it should be "" to begin with assertEquals("desc", linkedAsset.getDescription()); linkedAsset.updateDescription("test description"); assertEquals("test description", linkedAsset.getDescription()); assertTrue(getRepo().getSession().hasPendingChanges()); linkedAsset.updateTitle("This is a title"); assertTrue(getRepo().getSession().hasPendingChanges()); linkedAsset.checkin("ya"); // we can save without a checkin getRepo().getSession().save(); assertFalse(getRepo().getSession().hasPendingChanges()); try { linkedAsset.getPrecedingVersion().updateTitle("baaad"); fail("should not be able to do this"); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage()); } }
fail("should not be able to remove this."); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage());
} catch ( RulesRepositoryException e ) { assertNotNull( e.getMessage() );