Ejemplo n.º 1
0
 private void checkComponentSpec(
     ComponentSpec cs,
     String owner,
     String type,
     String creator,
     String name,
     Collection<Tag> tags,
     Map<String, String> views) {
   Assert.assertEquals(owner, cs.getOwner());
   Assert.assertEquals(type, cs.getComponentType());
   Assert.assertEquals(creator, cs.getCreatorUserId());
   Assert.assertEquals(name, cs.getComponentName());
   Assert.assertNotNull(cs.getDateCreated());
   Assert.assertNotNull(cs.getLastModified());
   Assert.assertEquals(cs.getViewStateCollection().size(), views.size());
   for (Entry<String, String> e : views.entrySet()) {
     Assert.assertTrue(findViewState(cs.getViewStateCollection(), e.getKey(), e.getValue()));
   }
   Assert.assertEquals(cs.getTagAssociationCollection().size(), tags.size());
   for (Tag t : tags) {
     Assert.assertTrue(findTags(cs.getTagAssociationCollection(), t));
   }
 }
Ejemplo n.º 2
0
  private ComponentSpec createComponentSpec(
      String id,
      String userId,
      String name,
      String type,
      String owner,
      List<Tag> tags,
      Map<String, String> views) {
    ComponentSpec cs = new ComponentSpec();
    cs.setComponentId(id);
    cs.setCreatorUserId(userId);
    cs.setComponentName(name);
    cs.setComponentType(type);
    cs.setOwner(owner);
    cs.setReferencedComponents(new ArrayList<ComponentSpec>());
    List<ViewState> viewStates = new ArrayList<ViewState>();
    for (Entry<String, String> e : views.entrySet()) {
      ViewState vs = new ViewState();
      ViewStatePK viewStatePK = new ViewStatePK();
      viewStatePK.setComponentId(cs.getComponentId());
      viewStatePK.setViewType(e.getKey());
      vs.setViewStatePK(viewStatePK);
      vs.setViewInfo(e.getValue());
      viewStates.add(vs);
    }
    cs.setViewStateCollection(viewStates);

    cs.setTagAssociationCollection(new ArrayList<TagAssociation>());
    for (Tag aTag : tags) {
      TagAssociation association = new TagAssociation();
      TagAssociationPK tagPK = new TagAssociationPK();
      tagPK.setComponentId(cs.getComponentId());
      tagPK.setTagId(aTag.getTagId());
      association.setTagAssociationPK(tagPK);
      association.setTagProperty(aTag.getTagProperty());
      cs.getTagAssociationCollection().add(association);
    }

    return cs;
  }