// 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.";