CompositePackageDescr extends PackageDescr { public void addPackageDescr(Resource resource, PackageDescr packageDescr) { if (!getNamespace().equals(packageDescr.getNamespace())) { throw new RuntimeException("Composing PackageDescr (" + packageDescr.getName() + ") in different namespaces (namespace=" + getNamespace() + " packageDescr=" + packageDescr.getNamespace() + ")" ); } internalAdd(resource, packageDescr); } CompositePackageDescr();  CompositePackageDescr(Resource resource, PackageDescr packageDescr); void addPackageDescr(Resource resource, PackageDescr packageDescr); CompositeAssetFilter getFilter(); void addFilter( KnowledgeBuilderImpl.AssetFilter f );  }
@Test public void addPackageDescrSamePkgUUID() { String pkgUUID = generateUUID(); PackageDescr toAdd = new PackageDescr(NAMESPACE); toAdd.setPreferredPkgUUID(pkgUUID); compositePackageDescr.addPackageDescr(new ByteArrayResource(), toAdd); assertTrue(compositePackageDescr.getPreferredPkgUUID().isPresent()); assertEquals(pkgUUID, compositePackageDescr.getPreferredPkgUUID().get()); toAdd = new PackageDescr(NAMESPACE); toAdd.setPreferredPkgUUID(pkgUUID); compositePackageDescr.addPackageDescr(new ByteArrayResource(), toAdd); assertEquals(pkgUUID, compositePackageDescr.getPreferredPkgUUID().get()); }
@Test(expected = RuntimeException.class) public void addPackageDescrDifferentPkgUUID() { String pkgUUID = generateUUID(); PackageDescr first = new PackageDescr(NAMESPACE); first.setPreferredPkgUUID(pkgUUID); assertTrue(first.getPreferredPkgUUID().isPresent()); compositePackageDescr.addPackageDescr(new ByteArrayResource(), first); assertTrue(compositePackageDescr.getPreferredPkgUUID().isPresent()); assertEquals(pkgUUID, compositePackageDescr.getPreferredPkgUUID().get()); pkgUUID = generateUUID(); PackageDescr second = new PackageDescr(NAMESPACE); second.setPreferredPkgUUID(pkgUUID); assertTrue(second.getPreferredPkgUUID().isPresent()); assertNotEquals(first.getPreferredPkgUUID().get(), second.getPreferredPkgUUID().get()); compositePackageDescr.addPackageDescr(new ByteArrayResource(), second); }