Package org.apache.ace.client.repository.object

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


    public void testAssociationsWithMovingEndpoints() throws Exception {
        final ArtifactObject b1 = createBasicBundleObject("thebundle", "1", null);
        final FeatureObject g1 = createBasicFeatureObject("thefeature");
       
        final Artifact2FeatureAssociation bg = runAndWaitForEvent(new Callable<Artifact2FeatureAssociation>() {
            public Artifact2FeatureAssociation call() throws Exception {
                Map<String, String> properties = new HashMap<String, String>();
                properties.put(BundleHelper.KEY_ASSOCIATION_VERSIONSTATEMENT, "[1,3)");
                return m_artifact2featureRepository.create(b1, properties, g1, null);
            }
        }, false, Artifact2FeatureAssociation.TOPIC_ADDED);

        assertTrue("The left side of the association should now be b1; we find "
            + bg.getLeft().size() + " bundles on the left side of the association.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b1));
        assertTrue("The right side of the association should now be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertEquals("b1 should be assocated with g1", g1, b1.getFeatures().get(0));
        assertEquals("g1 should be assocated with b1", b1, g1.getArtifacts().get(0));

        final ArtifactObject b2 = runAndWaitForEvent(new Callable<ArtifactObject>() {
            public ArtifactObject call() throws Exception {
                return createBasicBundleObject("thebundle", "2", null);
            }
        }, false, Artifact2FeatureAssociation.TOPIC_CHANGED);

        assertTrue("The left side of the association should no longer be b1; we find "
            + bg.getLeft().size() + " bundles.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b1));
        assertTrue("The left side of the association should now be b2.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b2));
        assertTrue("The right side of the association should now be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertEquals("b1 should not be associated with any feature.", 0, b1.getFeatures().size());
        assertEquals("b2 should now be assocation with g1", g1, b2.getFeatures().get(0));
        assertEquals("g1 should be assocation with b2", b2, g1.getArtifacts().get(0));
        assertEquals("g1 should be associated with one bundle", 1, g1.getArtifacts().size());

        ArtifactObject b3 = createBasicBundleObject("thebundle", "3", null);

        assertTrue("The left side of the association should no longer be b1.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b1));
        assertTrue("The left side of the association should now be b2.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b2));
        assertTrue("The left side of the association should not be b3.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b3));
        assertTrue("The right side of the association should now be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertEquals("b1 should not be associated with any feature.", 0, b1.getFeatures().size());
        assertEquals("b2 should now be assocation with g1", g1, b2.getFeatures().get(0));
        assertEquals("b3 should not be associated with any feature.", 0, b3.getFeatures().size());
        assertEquals("g1 should be assocation with b2", b2, g1.getArtifacts().get(0));
        assertEquals("g1 should be associated with one bundle", 1, g1.getArtifacts().size());

        ArtifactObject b15 = createBasicBundleObject("thebundle", "1.5", null);

        assertTrue("The left side of the association should no longer be b1.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b1));
        assertTrue("The left side of the association should not be b15.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b15));
        assertTrue("The left side of the association should now be b2.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b2));
        assertTrue("The left side of the association should not be b3.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b3));
        assertTrue("The right side of the association should now be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertEquals("b1 should not be associated with any feature.", 0, b1.getFeatures().size());
        assertEquals("b15 should not be associated with any feature.", 0, b15.getFeatures().size());
        assertEquals("b2 should now be assocation with g1", g1, b2.getFeatures().get(0));
        assertEquals("b3 should not be associated with any feature.", 0, b3.getFeatures().size());
        assertEquals("g1 should be assocation with b2", b2, g1.getArtifacts().get(0));
        assertEquals("g1 should be associated with one bundle", 1, g1.getArtifacts().size());

        runAndWaitForEvent(new Callable<Object>() {
            public Object call() throws Exception {
                m_artifactRepository.remove(b2);
                return null;
            }
        }, false, Artifact2FeatureAssociation.TOPIC_CHANGED);

        // note that we cannot test anything for b2: this has been removed, and now has no
        // defined state.
        assertTrue("The left side of the association should no longer be b1.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b1));
        assertTrue("The left side of the association should now be b15.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b15));
        assertTrue("The left side of the association should not be b3.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b3));
        assertTrue("The right side of the association should now be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertEquals("b1 should not be associated with any feature.", 0, b1.getFeatures().size());
        assertEquals("b15 should now be assocation with g1", g1, b15.getFeatures().get(0));
        assertEquals("b3 should not be associated with any feature.", 0, b3.getFeatures().size());
        assertEquals("g1 should be assocation with b15", b15, g1.getArtifacts().get(0));
        assertEquals("g1 should be associated with one bundle", 1, g1.getArtifacts().size());
View Full Code Here


     */
    public void testRemoveBundleFeature() throws Exception {
        final ArtifactObject b1 = createBasicBundleObject("thebundle", "1", null);
        final FeatureObject g1 = createBasicFeatureObject("thefeature");

        final Artifact2FeatureAssociation bg = runAndWaitForEvent(new Callable<Artifact2FeatureAssociation>() {
            public Artifact2FeatureAssociation call() throws Exception {
                return m_artifact2featureRepository.create("(&(" + BundleHelper.KEY_SYMBOLICNAME + "=thebundle)(|("
                    + BundleHelper.KEY_VERSION + ">=1)(" + BundleHelper.KEY_VERSION + "=<3))(!("
                    + BundleHelper.KEY_VERSION + "=3)))", "(name=thefeature)");
            }
        }, false, Artifact2FeatureAssociation.TOPIC_ADDED);

        final DistributionObject l1 = createBasicDistributionObject("thedistribution");

        final Feature2DistributionAssociation gtl = runAndWaitForEvent(new Callable<Feature2DistributionAssociation>() {
            public Feature2DistributionAssociation call() throws Exception {
                return m_feature2distributionRepository.create("(name=thefeature)", "(name=thedistribution)");
            }
        }, false, Feature2DistributionAssociation.TOPIC_ADDED);

        assertTrue("The left side of the BG-association should be b1.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b1));
        assertTrue("The right side of the BG-association should be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertTrue("The left side of the GtL-association should be g1.", (gtl.getLeft().size() == 1) && gtl.getLeft().contains(g1));
        assertTrue("The right side of the GtL-association should be l1.", (gtl.getRight().size() == 1) && gtl.getRight().contains(l1));
        assertTrue("The bundlefeature association should be satisfied.", bg.isSatisfied());
        assertTrue("The feature2distribution association should be satisfied.", gtl.isSatisfied());
        assertEquals("Bundle b1 should be associated to one feature.", 1, b1.getFeatures().size());
        assertEquals("Distribution l1 should be associated to one feature.", 1, l1.getFeatures().size());

        // remove the feature
        runAndWaitForEvent(new Callable<Object>() {
            public Object call() throws Exception {
                m_featureRepository.remove(g1);
                return null;
            }
        }, false, Artifact2FeatureAssociation.TOPIC_CHANGED, Feature2DistributionAssociation.TOPIC_CHANGED);

        assertFalse("The bundlefeature association shouldn not be satisfied.", gtl.isSatisfied());
        assertFalse("The feature2distribution assocation should not be satisfied.", bg.isSatisfied());

        assertEquals("Bundle b1 shouldn't be associated to any feature, but is associated to " + b1.getFeatures(), 0, b1.getFeatures().size());
        assertEquals("Distribution l1 shouldn't be associated to any feature.", 0, l1.getFeatures().size());

        cleanUp();
View Full Code Here

                return go;
            }
        }, false, TOPIC_ADDED);

        ArtifactObject a1 = m_artifactRepository.importArtifact(noTemplateFile.toURI().toURL(), true);
        Artifact2FeatureAssociation a2g = m_artifact2featureRepository.create(a1, go);

        final StatefulTargetObject sgo = findStatefulTarget("templatetarget2");

        // create a deploymentversion
        assertTrue("With the new assignments, the SGO should need approval.", sgo.needsApprove());
View Full Code Here

        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();
View Full Code Here

    @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() + ".";
View Full Code Here

        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";
View Full Code Here

            //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.";
View Full Code Here

                return go;
            }
        }, false, TOPIC_ADDED);

        ArtifactObject a1 = m_artifactRepository.importArtifact(noTemplateFile.toURI().toURL(), true);
        Artifact2FeatureAssociation a2g = m_artifact2featureRepository.create(a1, go);

        final StatefulTargetObject sgo = findStatefulTarget("templatetarget2");

        // create a deploymentversion
        assertTrue("With the new assignments, the SGO should need approval.", sgo.needsApprove());
View Full Code Here

    public void testAssociationsWithMovingEndpoints() throws Exception {
        final ArtifactObject b1 = createBasicBundleObject("thebundle", "1", null);
        final FeatureObject g1 = createBasicFeatureObject("thefeature");

        final Artifact2FeatureAssociation bg = runAndWaitForEvent(new Callable<Artifact2FeatureAssociation>() {
            public Artifact2FeatureAssociation call() throws Exception {
                Map<String, String> properties = new HashMap<String, String>();
                properties.put(BundleHelper.KEY_ASSOCIATION_VERSIONSTATEMENT, "[1,3)");
                return m_artifact2featureRepository.create(b1, properties, g1, null);
            }
        }, false, Artifact2FeatureAssociation.TOPIC_ADDED);

        assertTrue("The left side of the association should now be b1; we find "
            + bg.getLeft().size() + " bundles on the left side of the association.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b1));
        assertTrue("The right side of the association should now be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertEquals("b1 should be assocated with g1", g1, b1.getFeatures().get(0));
        assertEquals("g1 should be assocated with b1", b1, g1.getArtifacts().get(0));

        final ArtifactObject b2 = runAndWaitForEvent(new Callable<ArtifactObject>() {
            public ArtifactObject call() throws Exception {
                return createBasicBundleObject("thebundle", "2", null);
            }
        }, false, Artifact2FeatureAssociation.TOPIC_CHANGED);

        assertTrue("The left side of the association should no longer be b1; we find "
            + bg.getLeft().size() + " bundles.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b1));
        assertTrue("The left side of the association should now be b2.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b2));
        assertTrue("The right side of the association should now be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertEquals("b1 should not be associated with any feature.", 0, b1.getFeatures().size());
        assertEquals("b2 should now be assocation with g1", g1, b2.getFeatures().get(0));
        assertEquals("g1 should be assocation with b2", b2, g1.getArtifacts().get(0));
        assertEquals("g1 should be associated with one bundle", 1, g1.getArtifacts().size());

        ArtifactObject b3 = createBasicBundleObject("thebundle", "3", null);

        assertTrue("The left side of the association should no longer be b1.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b1));
        assertTrue("The left side of the association should now be b2.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b2));
        assertTrue("The left side of the association should not be b3.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b3));
        assertTrue("The right side of the association should now be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertEquals("b1 should not be associated with any feature.", 0, b1.getFeatures().size());
        assertEquals("b2 should now be assocation with g1", g1, b2.getFeatures().get(0));
        assertEquals("b3 should not be associated with any feature.", 0, b3.getFeatures().size());
        assertEquals("g1 should be assocation with b2", b2, g1.getArtifacts().get(0));
        assertEquals("g1 should be associated with one bundle", 1, g1.getArtifacts().size());

        ArtifactObject b15 = createBasicBundleObject("thebundle", "1.5", null);

        assertTrue("The left side of the association should no longer be b1.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b1));
        assertTrue("The left side of the association should not be b15.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b15));
        assertTrue("The left side of the association should now be b2.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b2));
        assertTrue("The left side of the association should not be b3.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b3));
        assertTrue("The right side of the association should now be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertEquals("b1 should not be associated with any feature.", 0, b1.getFeatures().size());
        assertEquals("b15 should not be associated with any feature.", 0, b15.getFeatures().size());
        assertEquals("b2 should now be assocation with g1", g1, b2.getFeatures().get(0));
        assertEquals("b3 should not be associated with any feature.", 0, b3.getFeatures().size());
        assertEquals("g1 should be assocation with b2", b2, g1.getArtifacts().get(0));
        assertEquals("g1 should be associated with one bundle", 1, g1.getArtifacts().size());

        runAndWaitForEvent(new Callable<Object>() {
            public Object call() throws Exception {
                m_artifactRepository.remove(b2);
                return null;
            }
        }, false, Artifact2FeatureAssociation.TOPIC_CHANGED);

        // note that we cannot test anything for b2: this has been removed, and now has no
        // defined state.
        assertTrue("The left side of the association should no longer be b1.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b1));
        assertTrue("The left side of the association should now be b15.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b15));
        assertTrue("The left side of the association should not be b3.", (bg.getLeft().size() == 1) && !bg.getLeft().contains(b3));
        assertTrue("The right side of the association should now be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertEquals("b1 should not be associated with any feature.", 0, b1.getFeatures().size());
        assertEquals("b15 should now be assocation with g1", g1, b15.getFeatures().get(0));
        assertEquals("b3 should not be associated with any feature.", 0, b3.getFeatures().size());
        assertEquals("g1 should be assocation with b15", b15, g1.getArtifacts().get(0));
        assertEquals("g1 should be associated with one bundle", 1, g1.getArtifacts().size());
View Full Code Here

     */
    public void testRemoveBundleFeature() throws Exception {
        final ArtifactObject b1 = createBasicBundleObject("thebundle", "1", null);
        final FeatureObject g1 = createBasicFeatureObject("thefeature");

        final Artifact2FeatureAssociation bg = runAndWaitForEvent(new Callable<Artifact2FeatureAssociation>() {
            public Artifact2FeatureAssociation call() throws Exception {
                return m_artifact2featureRepository.create("(&(" + BundleHelper.KEY_SYMBOLICNAME + "=thebundle)(|("
                    + BundleHelper.KEY_VERSION + ">=1)(" + BundleHelper.KEY_VERSION + "=<3))(!("
                    + BundleHelper.KEY_VERSION + "=3)))", "(name=thefeature)");
            }
        }, false, Artifact2FeatureAssociation.TOPIC_ADDED);

        final DistributionObject l1 = createBasicDistributionObject("thedistribution");

        final Feature2DistributionAssociation gtl = runAndWaitForEvent(new Callable<Feature2DistributionAssociation>() {
            public Feature2DistributionAssociation call() throws Exception {
                return m_feature2distributionRepository.create("(name=thefeature)", "(name=thedistribution)");
            }
        }, false, Feature2DistributionAssociation.TOPIC_ADDED);

        assertTrue("The left side of the BG-association should be b1.", (bg.getLeft().size() == 1) && bg.getLeft().contains(b1));
        assertTrue("The right side of the BG-association should be g1.", (bg.getRight().size() == 1) && bg.getRight().contains(g1));
        assertTrue("The left side of the GtL-association should be g1.", (gtl.getLeft().size() == 1) && gtl.getLeft().contains(g1));
        assertTrue("The right side of the GtL-association should be l1.", (gtl.getRight().size() == 1) && gtl.getRight().contains(l1));
        assertTrue("The bundlefeature association should be satisfied.", bg.isSatisfied());
        assertTrue("The feature2distribution association should be satisfied.", gtl.isSatisfied());
        assertEquals("Bundle b1 should be associated to one feature.", 1, b1.getFeatures().size());
        assertEquals("Distribution l1 should be associated to one feature.", 1, l1.getFeatures().size());

        // remove the feature
        runAndWaitForEvent(new Callable<Object>() {
            public Object call() throws Exception {
                m_featureRepository.remove(g1);
                return null;
            }
        }, false, Artifact2FeatureAssociation.TOPIC_CHANGED, Feature2DistributionAssociation.TOPIC_CHANGED);

        assertFalse("The bundlefeature association shouldn not be satisfied.", gtl.isSatisfied());
        assertFalse("The feature2distribution assocation should not be satisfied.", bg.isSatisfied());

        assertEquals("Bundle b1 shouldn't be associated to any feature, but is associated to " + b1.getFeatures(), 0, b1.getFeatures().size());
        assertEquals("Distribution l1 shouldn't be associated to any feature.", 0, l1.getFeatures().size());

        cleanUp();
View Full Code Here

TOP

Related Classes of org.apache.ace.client.repository.object.Artifact2FeatureAssociation

Copyright © 2018 www.massapicom. 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.