Examples of GroupObject


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

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

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

        attributes.put("myattribute", "theattribute");
        attributes.put("name", "attname");
        Map<String, String> tags = new HashMap<String, String>();

        assert m_groupRepository != null : "Something has gone wrong injecting the bundle repository.";
        GroupObject g1 = m_groupRepository.create(attributes, tags);
        g1.addTag("mytag", "thetag");
        g1.addTag("name", "tagname");
        g1.addTag("difficult", ")diffi)c*ul\\t");


        assert m_groupRepository.get(createLocalFilter("(myattribute=*)")).size() == 1 : "There should be a myattribute in b1.";
        assert m_groupRepository.get(createLocalFilter("(myattribute=theattribute)")).size() == 1 : "There should be myattribute=theattribute in b1.";
        assert m_groupRepository.get(createLocalFilter("(myattribute=thetag)")).size() == 0 : "There should not be myattribute=thetag in b1.";
View Full Code Here

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

        // 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);
        g3expectedBundles.remove(b2);

        assert b1groups.containsAll(b1expectedGroups) && b1expectedGroups.containsAll(b1groups) : "b1 should be associated to exactly groups 2 and 3.";
View Full Code Here

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

     * by TestAssociations.
     */
    @Test( groups = { TestUtils.UNIT } )
    public void TestGroup2LicenseAssociations() {
        initializeRepositoryAdmin();
        GroupObject g1 = createBasicGroupObject("group1");
        LicenseObject l1 = createBasicLicenseObject("license1");
        Group2LicenseAssociation g2l1 = m_group2licenseRepository.create(g1, l1);

        assert (g2l1.getLeft().size() == 1) && g2l1.getLeft().contains(g1) : "Left side of the association should be our group.";
        assert (g2l1.getRight().size() == 1) &&  g2l1.getRight().contains(l1) : "Right side of the association should be our license.";

        assert g1.getArtifacts().size() == 0 : "Group 1 should not be associated with any bundles; it is associated with " + g1.getArtifacts().size() + ".";
        assert g1.getLicenses().size() == 1 : "Group 1 should be associated with exactly one license; it is associated with " + g1.getLicenses().size() + ".";

        assert l1.getGroups().size() == 1 : "License 1 should be associated with exactly one group; it is associated with " + l1.getGroups().size() + ".";
        assert l1.getGateways().size() == 0 : "License 1 should not be associated with any gateways; it is associated with " + l1.getGateways().size() + ".";
    }
View Full Code Here

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

    @Test( groups = { TestUtils.UNIT } )
    public void testGetAssociationsWith() {
        initializeRepositoryAdmin();
        ArtifactObject b1 = createBasicBundleObject("bundle1");
        GroupObject g1 = createBasicGroupObject("group1");
        Artifact2GroupAssociation b2g1 = m_artifact2groupRepository.create(b1, g1);

        List<Artifact2GroupAssociation> b1Associations = b1.getAssociationsWith(g1);
        List<Artifact2GroupAssociation> g1Associations = g1.getAssociationsWith(b1);

        assert b1Associations.size() == 1 : "The bundle has exactly one association to the group, but it shows " + b1Associations.size() + ".";
        assert b1Associations.get(0) == b2g1 : "The bundle's association should be the one we created.";

        assert g1Associations.size() == 1 : "The group has exactly one association to the bundle.";
View Full Code Here

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

    @Test( groups = { TestUtils.UNIT } )
    public void testAssociationsWithLists() {
        ArtifactObject b1 = createBasicBundleObject("b1");
        ArtifactObject b2 = createBasicBundleObject("b2");
        ArtifactObject b3 = createBasicBundleObject("b3");
        GroupObject g1 = createBasicGroupObject("g1");
        GroupObject g2 = createBasicGroupObject("g2");
        GroupObject g3 = createBasicGroupObject("g3");

        List<ArtifactObject> bundles = new ArrayList<ArtifactObject>();
        bundles.add(b1);
        bundles.add(b2);
        List<GroupObject> groups = new ArrayList<GroupObject>();
        groups.add(g1);
        groups.add(g3);

        Artifact2GroupAssociation bg = m_artifact2groupRepository.create(bundles, groups);

        assert bg.getLeft().size() == 2 : "We expect two bundles on the left side of the association.";
        assert bg.getRight().size() == 2 : "We expect two groups 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<GroupObject> foundGroups = b1.getGroups();
        assert foundGroups.size() == 2 : "b1 should be associated with two groups.";
        assert foundGroups.contains(g1) : "b1 should be associated with g1";
        assert !foundGroups.contains(g2) : "b1 not should be associated with g2";
        assert foundGroups.contains(g3) : "b1 should be associated with g3";

        foundGroups = b3.getGroups();
        assert foundGroups.size() == 0 : "b3 should not be associated with any groups.";

        List<ArtifactObject> foundBundles = g3.getArtifacts();
        assert foundBundles.size() == 2 : "g1 should be associated with two groups.";
        assert foundBundles.contains(b1) : "g1 should be associated with b1";
        assert foundBundles.contains(b2) : "g1 should be associated with b2";
        assert !foundBundles.contains(b3) : "g1 should not be associated with b3";
    }
View Full Code Here

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

    }

    @Test( groups = { TestUtils.UNIT } )
    public void testAssociationsWithCardinality() {
        ArtifactObject b1 = createBasicBundleObject("b1");
        GroupObject g1 = createBasicGroupObject("g1");
        GroupObject g2 = createBasicGroupObject("g2");
        GroupObject g3 = createBasicGroupObject("g3");

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

        try {
            m_artifact2groupRepository.create(props, tags);
            assert false : "There are three matches for the group, 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");

        Artifact2GroupAssociation bg = m_artifact2groupRepository.create(props, tags);
        assert b1.getGroups().size() == 3 : "The bundle should be associated to three groups.";
        assert (g1.getArtifacts().size() == 1) && g1.getArtifacts().contains(b1) : "g1 should be associated to only b1.";
        assert (g2.getArtifacts().size() == 1) && g2.getArtifacts().contains(b1) : "g1 should be associated to only b1.";
        assert (g3.getArtifacts().size() == 1) && g3.getArtifacts().contains(b1) : "g1 should be associated to only b1.";
    }
View Full Code Here

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

                for (GroupObject feature : m_featureRepository.get()) {
                    add(feature);
                }
            }
            public void handleEvent(org.osgi.service.event.Event event) {
                GroupObject feature = (GroupObject) event.getProperty(GroupObject.EVENT_ENTITY);
                String topic = (String) event.getProperty(EventConstants.EVENT_TOPIC);
                if (GroupObject.TOPIC_ADDED.equals(topic)) {
                    add(feature);
                }
                if (GroupObject.TOPIC_REMOVED.equals(topic)) {
                    remove(feature);
                }
                if (GroupObject.TOPIC_CHANGED.equals(topic)) {
                    change(feature);
                }
            }
            private void add(GroupObject feature) {
                Item item = addItem(feature.getName());
                item.getItemProperty(OBJECT_NAME).setValue(feature.getName());
                item.getItemProperty(OBJECT_DESCRIPTION).setValue(feature.getDescription());
                Button removeLinkButton = new RemoveLinkButton<GroupObject>(feature, m_artifactsPanel, m_distributionsPanel) {
                    @Override
                    protected void removeLinkFromLeft(GroupObject object, RepositoryObject other) {
                        List<Artifact2GroupAssociation> associations = object.getAssociationsWith((ArtifactObject) other);
                        for (Artifact2GroupAssociation association : associations) {
View Full Code Here

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

        }
        return null;
    }

    private void deleteFeature(String name) {
        GroupObject feature = getFeature(name);
        if (feature != null) {
            m_featureRepository.remove(feature);
            // TODO cleanup links?
        }
    }
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.