Examples of ArtifactObject


Examples of org.apache.ace.client.repository.object.ArtifactObject

     * @throws InvalidSyntaxException
     */
    @Test(groups = { TestUtils.UNIT })
    public void testArtifactObjectAndRepository() throws InvalidSyntaxException {
        // Create a very simple artifact.
        ArtifactObject a = createBasicArtifactObject("myartifact", "1.0.0", "1");

        // Try to create an illegal one
        try {
            createBasicArtifactObject("");
            assert false : "Creating an artifact with an empty name is not allowed.";
        }
        catch (IllegalArgumentException iae) {
            // expected
        }

        // Even though the artifact is not yet associated to a feature, try to get its features.
        List<FeatureObject> features = a.getFeatures();

        assert features.size() == 0 : "The artifact is not associated, so it should not return any features.";

        assert a.getAttribute(BundleHelper.KEY_SYMBOLICNAME).equals("myartifact") : "We should be able to read an attribute we just put in ourselves.";

        a.addTag("mytag", "myvalue");

        assert a.getTag("mytag").equals("myvalue") : "We should be able to read an attribute we just put in ourselves.";
        assert a.getTag(BundleHelper.KEY_SYMBOLICNAME) == null : "We should not find an attribute value when asking for a tag.";

        a.addTag(BundleHelper.KEY_SYMBOLICNAME, "mytagname");

        assert a.getTag(BundleHelper.KEY_SYMBOLICNAME).equals("mytagname") : "We can adds tags that have the same name as a artifact, but still return another value.";

        Dictionary<String, Object> dict = a.getDictionary();

        assert dict.get("mytag") == "myvalue" : "The dictionary of the object should contain all tags.";
        assert dict.get(BundleHelper.KEY_VERSION).equals("1.0.0") : "The dictionary of the object should contain all attributes; we found " + dict.get(BundleHelper.KEY_VERSION);
        String[] foundNames = (String[]) dict.get(BundleHelper.KEY_SYMBOLICNAME);
        assert foundNames.length == 2 : "For keys which are used both as a value and as a tag, we should get back both from the dictionary in an array.";
        assert (foundNames[0].equals("myartifact") && foundNames[1].equals("mytagname")) ||
            (foundNames[1].equals("myartifact") && foundNames[0].equals("mytagname")) : "The order is undefined, but we should find both the items we put in for '" + BundleHelper.KEY_SYMBOLICNAME + "'.";

        assert m_artifactRepository.get().size() == 1 : "The repository should contain exactly one artifact.";
        assert m_artifactRepository.get().get(0).equals(a) : "The repository should contain exactly our artifact.";

        ArtifactObject b2 = createBasicArtifactObject("myotherartifact", "1");

        assert m_artifactRepository.get(createLocalFilter("(" + BundleHelper.KEY_SYMBOLICNAME + "=myartifact)")).size() == 1 : "When filtering for our artifact, we should find only that.";
        assert m_artifactRepository.get(createLocalFilter("(" + BundleHelper.KEY_VERSION + "=1.0.0)")).size() == 2 : "When filtering for a version, we should find two artifacts.";

        try {
            createBasicArtifactObject("myartifact", "1.0.0");
            assert false : "Adding a artifact which is identical to one already in the repository should be illegal.";
        }
        catch (IllegalArgumentException iae) {
            // expected
        }

        try {
            b2.addAttribute("thenewattribute", "withsomevalue");
        }
        catch (UnsupportedOperationException uoe) {
            assert false : "Adding arbitrary attributes to a artifact object should be allowed.";
        }

        try {
            b2.addAttribute(BundleHelper.KEY_SYMBOLICNAME, "artifact.42");
            assert false : "Changing key attributes in a artifact should not be allowed.";
        }
        catch (UnsupportedOperationException uoe) {
            // expected
        }
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

    /**
     * Tests that we can create artifacts which contain a certain size (estimate). See ACE-384.
     */
    @Test(groups = { TestUtils.UNIT })
    public void testArtifactObjectSize() {
        ArtifactObject artifactWithSize = createBasicArtifactObject("myartifact", "1.0.0", "10");
        assert artifactWithSize.getSize() == 10 : "The artifact did not have a valid size?!";

        ArtifactObject artifactWithoutSize = createBasicArtifactObject("artifactWithoutSize", "1.0.0", null);
        assert artifactWithoutSize.getSize() == -1L : "The artifact did have a size?!";

        ArtifactObject artifactWithInvalidSize = createBasicArtifactObject("artifactWithInvalidSize", "1.0.0", "xyz");
        assert artifactWithInvalidSize.getSize() == -1L : "The artifact did have a size?!";
    }
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

     */
    @Test(groups = { TestUtils.UNIT })
    public void testAssociations() {
        initializeRepositoryAdmin();
        // Create two, rather boring, artifacts.
        ArtifactObject b1 = createBasicArtifactObject("artifact1");
        ArtifactObject b2 = createBasicArtifactObject("artifact2");

        // Create three features.
        FeatureObject g1 = createBasicFeatureObject("feature1");
        FeatureObject g2 = createBasicFeatureObject("feature2");
        FeatureObject g3 = createBasicFeatureObject("feature3");

        // Create some associations.
        Artifact2FeatureAssociation b2g1 = m_artifact2FeatureRepository.create(b1, g2);
        assert b2g1 != null;
        Artifact2FeatureAssociation b2g2 = m_artifact2FeatureRepository.create(b2, g1);
        assert b2g2 != null;
        Artifact2FeatureAssociation b2g3 = m_artifact2FeatureRepository.create(b1, g3);
        assert b2g3 != null;
        Artifact2FeatureAssociation b2g4 = m_artifact2FeatureRepository.create(b2, g3);
        assert b2g4 != null;

        // Do some basic checks on the repositories.
        assert m_artifactRepository.get().size() == 2 : "We should have two artifacts in our repository; we found " + m_artifactRepository.get().size() + ".";
        assert m_featureRepository.get().size() == 3 : "We should have three features in our repository; we found " + m_featureRepository.get().size() + ".";
        assert m_artifact2FeatureRepository.get().size() == 4 : "We should have four associations in our repository; we found " + m_artifact2FeatureRepository.get().size() + ".";

        assert (b2g4.getLeft().size() == 1) && b2g4.getLeft().contains(b2) : "The left side of the fourth association should be artifact 2.";
        assert (b2g4.getRight().size() == 1) && b2g4.getRight().contains(g3) : "The right side of the fourth association should be feature 3.";

        // Check the wiring: what is wired to what?
        List<FeatureObject> b1features = b1.getFeatures();
        List<FeatureObject> b2features = b2.getFeatures();

        List<ArtifactObject> g1artifacts = g1.getArtifacts();
        List<ArtifactObject> g2artifacts = g2.getArtifacts();
        List<ArtifactObject> g3artifacts = g3.getArtifacts();
        List<DistributionObject> g1distributions = g1.getDistributions();
        List<DistributionObject> g2distributions = g2.getDistributions();
        List<DistributionObject> g3distributions = g3.getDistributions();

        assert g1distributions.size() == 0 : "Feature one should not have any associations to distributions; we found " + g1distributions.size() + ".";
        assert g2distributions.size() == 0 : "Feature two should not have any associations to distributions; we found " + g2distributions.size() + ".";
        assert g3distributions.size() == 0 : "Feature three should not have any associations to distributions; we found " + g3distributions.size() + ".";

        List<FeatureObject> b1expectedFeatures = new ArrayList<FeatureObject>();
        b1expectedFeatures.add(g2);
        b1expectedFeatures.add(g3);
        List<FeatureObject> b2expectedFeatures = new ArrayList<FeatureObject>();
        b2expectedFeatures.add(g1);
        b2expectedFeatures.add(g3);

        List<ArtifactObject> g1expectedArtifacts = new ArrayList<ArtifactObject>();
        g1expectedArtifacts.add(b2);
        List<ArtifactObject> g2expectedArtifacts = new ArrayList<ArtifactObject>();
        g2expectedArtifacts.add(b1);
        List<ArtifactObject> g3expectedArtifacts = new ArrayList<ArtifactObject>();
        g3expectedArtifacts.add(b1);
        g3expectedArtifacts.add(b2);

        assert b1features.containsAll(b1expectedFeatures) && b1expectedFeatures.containsAll(b1features) : "b1 should be associated to exactly features 2 and 3.";
        assert b2features.containsAll(b2expectedFeatures) && b2expectedFeatures.containsAll(b2features) : "b2 should be associated to exactly features 1 and 3.";

        assert g1artifacts.containsAll(g1expectedArtifacts) && g1expectedArtifacts.containsAll(g1artifacts) : "g1 should be associated to exactly artifact 2.";
        assert g2artifacts.containsAll(g2expectedArtifacts) && g2expectedArtifacts.containsAll(g2artifacts) : "g2 should be associated to exactly artifact 1.";
        assert g3artifacts.containsAll(g3expectedArtifacts) && g3expectedArtifacts.containsAll(g3artifacts) : "g3 should be associated to exactly artifacts 1 and 2.";

        m_artifact2FeatureRepository.remove(b2g4);

        b1features = b1.getFeatures();
        b2features = b2.getFeatures();
        g1artifacts = g1.getArtifacts();
        g2artifacts = g2.getArtifacts();
        g3artifacts = g3.getArtifacts();

        b2expectedFeatures.remove(g3);
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

        assert g3artifacts.containsAll(g3expectedArtifacts) && g3expectedArtifacts.containsAll(g3artifacts) : "g3 should be associated to exactly artifact 1.";
    }

    @Test(groups = { TestUtils.UNIT })
    public void testAssociationsWithCardinality() {
        ArtifactObject a1 = createBasicArtifactObject("a1");
        FeatureObject f1 = createBasicFeatureObject("f1");
        FeatureObject f2 = createBasicFeatureObject("f2");
        FeatureObject f3 = createBasicFeatureObject("f3");

        Map<String, String> props = new HashMap<String, String>();
        props.put(Association.LEFT_ENDPOINT, "(" + BundleHelper.KEY_SYMBOLICNAME + "=a1)");
        props.put(Association.LEFT_CARDINALITY, "1");
        props.put(Association.RIGHT_ENDPOINT, "(" + FeatureObject.KEY_NAME + "=f*)");
        props.put(Association.RIGHT_CARDINALITY, "2");
        Map<String, String> tags = new HashMap<String, String>();

        try {
            m_artifact2FeatureRepository.create(props, tags);
            assert false : "There are three matches for the feature, but we have a cardinality of 2; we should expect a NPE because no comparator is provided.";
        }
        catch (NullPointerException npe) {
            // expected
        }

        props.put(Association.RIGHT_CARDINALITY, "3");

        Artifact2FeatureAssociation bg = m_artifact2FeatureRepository.create(props, tags);
        assert bg != null : "Assocating artifact to feature failed?!";

        assert a1.getFeatures().size() == 3 : "The artifact should be associated to three features.";
        assert (f1.getArtifacts().size() == 1) && f1.getArtifacts().contains(a1) : "g1 should be associated to only b1.";
        assert (f2.getArtifacts().size() == 1) && f2.getArtifacts().contains(a1) : "g1 should be associated to only b1.";
        assert (f3.getArtifacts().size() == 1) && f3.getArtifacts().contains(a1) : "g1 should be associated to only b1.";
    }
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

        assert (f3.getArtifacts().size() == 1) && f3.getArtifacts().contains(a1) : "g1 should be associated to only b1.";
    }

    @Test(groups = { TestUtils.UNIT })
    public void testAssociationsWithLists() {
        ArtifactObject b1 = createBasicArtifactObject("b1");
        ArtifactObject b2 = createBasicArtifactObject("b2");
        ArtifactObject b3 = createBasicArtifactObject("b3");
        FeatureObject g1 = createBasicFeatureObject("g1");
        FeatureObject g2 = createBasicFeatureObject("g2");
        FeatureObject g3 = createBasicFeatureObject("g3");

        List<ArtifactObject> artifacts = new ArrayList<ArtifactObject>();
        artifacts.add(b1);
        artifacts.add(b2);
        List<FeatureObject> features = new ArrayList<FeatureObject>();
        features.add(g1);
        features.add(g3);

        Artifact2FeatureAssociation bg = m_artifact2FeatureRepository.create(artifacts, features);

        assert bg.getLeft().size() == 2 : "We expect two artifacts on the left side of the association.";
        assert bg.getRight().size() == 2 : "We expect two features on the right side of the association.";

        assert bg.getLeft().contains(b1) : "b1 should be on the left side of the association.";
        assert bg.getLeft().contains(b2) : "b2 should be on the left side of the association.";
        assert !bg.getLeft().contains(b3) : "b3 should not be on the left side of the association.";
        assert bg.getRight().contains(g1) : "g1 should be on the right side of the association.";
        assert !bg.getRight().contains(g2) : "g2 should not be on the right side of the association.";
        assert bg.getRight().contains(g3) : "g3 should be on the right side of the association.";

        List<FeatureObject> foundFeatures = b1.getFeatures();
        assert foundFeatures.size() == 2 : "b1 should be associated with two features.";
        assert foundFeatures.contains(g1) : "b1 should be associated with g1";
        assert !foundFeatures.contains(g2) : "b1 not should be associated with g2";
        assert foundFeatures.contains(g3) : "b1 should be associated with g3";

        foundFeatures = b3.getFeatures();
        assert foundFeatures.size() == 0 : "b3 should not be associated with any features.";

        List<ArtifactObject> foundArtifacts = g3.getArtifacts();
        assert foundArtifacts.size() == 2 : "g1 should be associated with two features.";
        assert foundArtifacts.contains(b1) : "g1 should be associated with b1";
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

    }

    @Test(groups = { TestUtils.UNIT })
    public void testGetAssociationsWith() {
        initializeRepositoryAdmin();
        ArtifactObject a1 = createBasicArtifactObject("artifact1");
        FeatureObject f1 = createBasicFeatureObject("feature1");
        Artifact2FeatureAssociation a2f1 = m_artifact2FeatureRepository.create(a1, f1);

        List<Artifact2FeatureAssociation> b1Associations = a1.getAssociationsWith(f1);
        List<Artifact2FeatureAssociation> g1Associations = f1.getAssociationsWith(a1);

        assert b1Associations.size() == 1 : "The artifact has exactly one association to the feature, but it shows " + b1Associations.size() + ".";
        assert b1Associations.get(0) == a2f1 : "The artifact's association should be the one we created.";
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

        assert m_artifactRepository.get().size() == 2 : "We expect to find 2 artifacts, but we find " + m_artifactRepository.get().size();
    }

    @Test(groups = { TestUtils.UNIT })
    public void testSerialization() throws IOException {
        ArtifactObject b1 = createBasicArtifactObject("artifact1");
        ArtifactObject b2 = createBasicArtifactObject("artifact2");
        ArtifactObject b3 = createBasicArtifactObject("artifact3");

        FeatureObject g1 = createBasicFeatureObject("feature1");
        FeatureObject g2 = createBasicFeatureObject("feature2");

        m_artifact2FeatureRepository.create(b1, g1);
        m_artifact2FeatureRepository.create(b2, g2);
        m_artifact2FeatureRepository.create(b3, g2);

        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        RepositorySet store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] { m_artifactRepository, m_featureRepository, m_artifact2FeatureRepository }, null, "", true);
        new RepositorySerializer(store).toXML(buffer);
        initializeRepositoryAdmin();
        store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] { m_artifactRepository, m_featureRepository, m_artifact2FeatureRepository }, null, "", true);
        new RepositorySerializer(store).fromXML(new ByteArrayInputStream(buffer.toByteArray()));

        assert m_artifactRepository.get().size() == 3 : "We expect to find 3 artifacts, but we find " + m_artifactRepository.get().size();
        assert m_featureRepository.get().size() == 2 : "We expect to find 2 features, but we find " + m_featureRepository.get().size();
        assert m_artifact2FeatureRepository.get().size() == 3 : "We expect to find 3 associations, but we find " + m_artifact2FeatureRepository.get().size();
        assert b1.isAssociated(g1, FeatureObject.class) : "After serialization, b1 should still be associated with g1.";
        assert !b1.isAssociated(g2, FeatureObject.class) : "After serialization, b1 should not be associated with g1.";
        assert !b2.isAssociated(g1, FeatureObject.class) : "After serialization, b2 should not be associated with g2.";
        assert b2.isAssociated(g2, FeatureObject.class) : "After serialization, b2 should still be associated with g2.";
        assert !b3.isAssociated(g1, FeatureObject.class) : "After serialization, b3 should not be associated with g2.";
        assert b3.isAssociated(g2, FeatureObject.class) : "After serialization, b3 should still be associated with g2.";
    }
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

     * @throws InvalidSyntaxException
     */
    @Test( groups = { TestUtils.UNIT } )
    public void testBundleObjectAndRepository() throws InvalidSyntaxException {
        // Create a very simple bundle.
        ArtifactObject b = createBasicBundleObject("mybundle", "1.0.0");

        // Try to create an illegal one
        try {
            createBasicBundleObject("");
            assert false : "Creating a bundle with an empty name is not allowed.";
        }
        catch (IllegalArgumentException iae) {
            // expected
        }

        // Even though the bundle is not yet associated to a group, try to get its groups.
        List<GroupObject> groups = b.getGroups();

        assert groups.size() == 0 : "The bundle is not associated, so it should not return any groups.";

        assert b.getAttribute(BundleHelper.KEY_SYMBOLICNAME).equals("mybundle") : "We should be able to read an attribute we just put in ourselves.";

        b.addTag("mytag", "myvalue");

        assert b.getTag("mytag").equals("myvalue": "We should be able to read an attribute we just put in ourselves.";
        assert b.getTag(BundleHelper.KEY_SYMBOLICNAME) == null : "We should not find an attribute value when asking for a tag.";

        b.addTag(BundleHelper.KEY_SYMBOLICNAME, "mytagname");

        assert b.getTag(BundleHelper.KEY_SYMBOLICNAME).equals("mytagname") : "We can adds tags that have the same name as a bundle, but still return another value.";

        Dictionary<String, Object> dict = b.getDictionary();

        assert dict.get("mytag") == "myvalue" : "The dictionary of the object should contain all tags.";
        assert dict.get(BundleHelper.KEY_VERSION).equals("1.0.0") : "The dictionary of the object should contain all attributes; we found " + dict.get(BundleHelper.KEY_VERSION);
        String[] foundNames = (String[]) dict.get(BundleHelper.KEY_SYMBOLICNAME);
        assert foundNames.length == 2 : "For keys which are used both as a value and as a tag, we should get back both from the dictionary in an array.";
        assert (foundNames[0].equals("mybundle") && foundNames[1].equals("mytagname")) ||
        (foundNames[1].equals("mybundle") && foundNames[0].equals("mytagname")) : "The order is undefined, but we should find both the items we put in for '"+BundleHelper.KEY_SYMBOLICNAME+"'.";

        assert m_artifactRepository.get().size() == 1 : "The repository should contain exactly one bundle.";
        assert m_artifactRepository.get().get(0).equals(b) : "The repository should contain exactly our bundle.";

        ArtifactObject b2 = createBasicBundleObject("myotherbundle", "1");

        assert m_artifactRepository.get(createLocalFilter("(" + BundleHelper.KEY_SYMBOLICNAME + "=mybundle)")).size() == 1 : "When filtering for our bundle, we should find only that.";
        assert m_artifactRepository.get(createLocalFilter("(" + BundleHelper.KEY_VERSION + "=1.0.0)")).size() == 2 : "When filtering for a version, we should find two bundles.";

        try {
            createBasicBundleObject("mybundle", "1.0.0");
            assert false : "Adding a bundle which is identical to one already in the repository should be illegal.";
        }
        catch (IllegalArgumentException iae) {
            //expected
        }

        try {
            b2.addAttribute("thenewattribute", "withsomevalue");
        }
        catch (UnsupportedOperationException uoe) {
            assert false : "Adding arbitrary attributes to a bundle object should be allowed.";
        }

        try {
            b2.addAttribute(BundleHelper.KEY_SYMBOLICNAME, "bundle.42");
            assert false : "Changing key attributes in a bundle should not be allowed.";
        }
        catch (UnsupportedOperationException uoe) {
            //expected
        }
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

        assert m_artifactRepository.get().size() == 2 : "We expect to find 2 bundles, but we find " + m_artifactRepository.get().size();
    }

    @Test( groups = { TestUtils.UNIT } )
    public void testSerialization() {
        ArtifactObject b1 = createBasicBundleObject("bundle1");
        ArtifactObject b2 = createBasicBundleObject("bundle2");
        ArtifactObject b3 = createBasicBundleObject("bundle3");

        GroupObject g1 = createBasicGroupObject("group1");
        GroupObject g2 = createBasicGroupObject("group2");

        m_artifact2groupRepository.create(b1, g1);
        m_artifact2groupRepository.create(b2, g2);
        m_artifact2groupRepository.create(b3, g2);

        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        RepositorySet store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_artifactRepository, m_groupRepository, m_artifact2groupRepository}, null, "", true);
        new RepositorySerializer(store).toXML(buffer);
        initializeRepositoryAdmin();
        store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_artifactRepository, m_groupRepository, m_artifact2groupRepository}, null, "", true);
        new RepositorySerializer(store).fromXML(new ByteArrayInputStream(buffer.toByteArray()));

        assert m_artifactRepository.get().size() == 3 : "We expect to find 3 bundles, but we find " + m_artifactRepository.get().size();
        assert m_groupRepository.get().size() == 2 : "We expect to find 2 groups, but we find " + m_groupRepository.get().size();
        assert m_artifact2groupRepository.get().size() == 3 : "We expect to find 3 associations, but we find " + m_artifact2groupRepository.get().size();
        assert b1.isAssociated(g1, GroupObject.class) : "After serialization, b1 should still be associated with g1.";
        assert !b1.isAssociated(g2, GroupObject.class) : "After serialization, b1 should not be associated with g1.";
        assert !b2.isAssociated(g1, GroupObject.class) : "After serialization, b2 should not be associated with g2.";
        assert b2.isAssociated(g2, GroupObject.class) : "After serialization, b2 should still be associated with g2.";
        assert !b3.isAssociated(g1, GroupObject.class) : "After serialization, b3 should not be associated with g2.";
        assert b3.isAssociated(g2, GroupObject.class) : "After serialization, b3 should still be associated with g2.";
    }
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

     */
    @Test( groups = { TestUtils.UNIT } )
    public void testAssociations() {
        initializeRepositoryAdmin();
        // Create two, rather boring, bundles.
        ArtifactObject b1 = createBasicBundleObject("bundle1");
        ArtifactObject b2 = createBasicBundleObject("bundle2");

        // Create three groups.
        GroupObject g1 = createBasicGroupObject("group1");
        GroupObject g2 = createBasicGroupObject("group2");
        GroupObject g3 = createBasicGroupObject("group3");

        // Create some associations.
        Artifact2GroupAssociation b2g1 = m_artifact2groupRepository.create(b1, g2);
        assert b2g1 != null;
        Artifact2GroupAssociation b2g2 = m_artifact2groupRepository.create(b2, g1);
        assert b2g2 != null;
        Artifact2GroupAssociation b2g3 = m_artifact2groupRepository.create(b1, g3);
        assert b2g3 != null;
        Artifact2GroupAssociation b2g4 = m_artifact2groupRepository.create(b2, g3);
        assert b2g4 != null;

        // Do some basic checks on the repositories.
        assert m_artifactRepository.get().size() == 2 : "We should have two bundles in our repository; we found " + m_artifactRepository.get().size() + ".";
        assert m_groupRepository.get().size() == 3 : "We should have three groups in our repository; we found " + m_groupRepository.get().size() + ".";
        assert m_artifact2groupRepository.get().size() == 4 : "We should have four associations in our repository; we found " + m_artifact2groupRepository.get().size() + ".";

        assert (b2g4.getLeft().size() == 1) && b2g4.getLeft().contains(b2) : "The left side of the fourth association should be bundle 2.";
        assert (b2g4.getRight().size() == 1) && b2g4.getRight().contains(g3) : "The right side of the fourth association should be group 3.";

        // Check the wiring: what is wired to what?
        List<GroupObject> b1groups = b1.getGroups();
        List<GroupObject> b2groups = b2.getGroups();

        List<ArtifactObject> g1bundles = g1.getArtifacts();
        List<ArtifactObject> g2bundles = g2.getArtifacts();
        List<ArtifactObject> g3bundles = g3.getArtifacts();
        List<LicenseObject> g1licenses = g1.getLicenses();
        List<LicenseObject> g2licenses = g2.getLicenses();
        List<LicenseObject> g3licenses = g3.getLicenses();

        assert g1licenses.size() == 0 : "Group one should not have any associations to licenses; we found " + g1licenses.size() + ".";
        assert g2licenses.size() == 0 : "Group two should not have any associations to licenses; we found " + g2licenses.size() + ".";
        assert g3licenses.size() == 0 : "Group three should not have any associations to licenses; we found " + g3licenses.size() + ".";

        List<GroupObject> b1expectedGroups = new ArrayList<GroupObject>();
        b1expectedGroups.add(g2);
        b1expectedGroups.add(g3);
        List<GroupObject> b2expectedGroups = new ArrayList<GroupObject>();
        b2expectedGroups.add(g1);
        b2expectedGroups.add(g3);

        List<ArtifactObject> g1expectedBundles = new ArrayList<ArtifactObject>();
        g1expectedBundles.add(b2);
        List<ArtifactObject> g2expectedBundles = new ArrayList<ArtifactObject>();
        g2expectedBundles.add(b1);
        List<ArtifactObject> g3expectedBundles = new ArrayList<ArtifactObject>();
        g3expectedBundles.add(b1);
        g3expectedBundles.add(b2);

        assert b1groups.containsAll(b1expectedGroups) && b1expectedGroups.containsAll(b1groups) : "b1 should be associated to exactly groups 2 and 3.";
        assert b2groups.containsAll(b2expectedGroups) && b2expectedGroups.containsAll(b2groups) : "b2 should be associated to exactly groups 1 and 3.";

        assert g1bundles.containsAll(g1expectedBundles) && g1expectedBundles.containsAll(g1bundles) : "g1 should be associated to exactly bundle 2.";
        assert g2bundles.containsAll(g2expectedBundles) && g2expectedBundles.containsAll(g2bundles) : "g2 should be associated to exactly bundle 1.";
        assert g3bundles.containsAll(g3expectedBundles) && g3expectedBundles.containsAll(g3bundles) : "g3 should be associated to exactly bundles 1 and 2.";

        m_artifact2groupRepository.remove(b2g4);

        b1groups = b1.getGroups();
        b2groups = b2.getGroups();
        g1bundles = g1.getArtifacts();
        g2bundles = g2.getArtifacts();
        g3bundles = g3.getArtifacts();

        b2expectedGroups.remove(g3);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.