use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getRichAttributesWithHoldersForAttributeDefinitionGetVosFromResource.
@Test
public void getRichAttributesWithHoldersForAttributeDefinitionGetVosFromResource() throws Exception {
System.out.println(CLASS_NAME + "getRichAttributesWithHoldersForAttributeDefinitionGetVosFromResource");
//Prepare attribute, create it and set it with testing value
Attribute attribute = setAttributeInNamespace(AttributesManager.NS_VO_ATTR);
perun.getAttributesManagerBl().setAttribute(sess, vo2, attribute);
//Prepare richAttribute with holders (attribute is not needed but holders are needed)
RichAttribute richAttr = new RichAttribute();
richAttr.setPrimaryHolder(resource2InVo2);
List<RichAttribute> listOfRichAttributes = perun.getAttributesManagerBl().getRichAttributesWithHoldersForAttributeDefinition(sess, new AttributeDefinition(attribute), richAttr);
assertTrue("return only 1 vo", listOfRichAttributes.size() == 1);
assertTrue("primary holder is type of vo", listOfRichAttributes.get(0).getPrimaryHolder() instanceof Vo);
assertTrue("secondary holder is null", listOfRichAttributes.get(0).getSecondaryHolder() == null);
assertTrue("the Vo is vo2", vo2.equals(listOfRichAttributes.get(0).getPrimaryHolder()));
assertTrue("attribute in richAttribute is equals to our attribute", (listOfRichAttributes.get(0).getAttribute()).equals(attribute));
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getRichAttributesWithHoldersForAttributeDefinitionGetVosFromHost.
@Test
public void getRichAttributesWithHoldersForAttributeDefinitionGetVosFromHost() throws Exception {
System.out.println(CLASS_NAME + "getRichAttributesWithHoldersForAttributeDefinitionGetVosFromHost");
//Prepare attribute, create it and set it with testing value
Attribute attribute = setAttributeInNamespace(AttributesManager.NS_VO_ATTR);
perun.getAttributesManagerBl().setAttribute(sess, vo2, attribute);
perun.getAttributesManagerBl().setAttribute(sess, vo1, attribute);
//Prepare richAttribute with holders (attribute is not needed but holders are needed)
RichAttribute richAttr = new RichAttribute();
richAttr.setPrimaryHolder(host1OnFacility2);
List<RichAttribute> listOfRichAttributes = perun.getAttributesManagerBl().getRichAttributesWithHoldersForAttributeDefinition(sess, new AttributeDefinition(attribute), richAttr);
//Return facilities Administrator too if exists
assertTrue("return at least 2 vos", listOfRichAttributes.size() >= 2);
assertTrue("return maximum of 3 vos", listOfRichAttributes.size() <= 3);
assertTrue("primary holder is type of vo", listOfRichAttributes.get(0).getPrimaryHolder() instanceof Vo);
assertTrue("secondary holder is null", listOfRichAttributes.get(0).getSecondaryHolder() == null);
List<Vo> returnedVos = new ArrayList<Vo>();
for (RichAttribute ra : listOfRichAttributes) {
returnedVos.add((Vo) ra.getPrimaryHolder());
}
assertTrue("returned vos contains vo1", returnedVos.contains(vo1));
assertTrue("returned vos contains vo2", returnedVos.contains(vo2));
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method checkNamespaceList.
@Test
public void checkNamespaceList() throws Exception {
System.out.println(CLASS_NAME + "checkNamespaceList");
AttributeDefinition attrDef = new AttributeDefinition();
attrDef.setFriendlyName("attr-manager-test-attribute");
attrDef.setNamespace("urn:perun:facility:attribute-def:opt");
attrDef.setType(String.class.getName());
attrDef.setDescription("AttributesManagerTest");
Attribute attribute = new Attribute(attrDef);
List<Attribute> attributes = new ArrayList<Attribute>();
attributes.add(attribute);
attributesManager.checkNamespace(sess, attributes, "urn:perun:facility:attribute-def:opt");
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getRichAttributesWithHoldersForAttributeDefinitionGetVosFromKey.
@Test
public void getRichAttributesWithHoldersForAttributeDefinitionGetVosFromKey() throws Exception {
System.out.println(CLASS_NAME + "getRichAttributesWithHoldersForAttributeDefinitionGetVosFromKey");
//Prepare attribute, create it and set it with testing value
Attribute attribute = setAttributeInNamespace(AttributesManager.NS_VO_ATTR);
perun.getAttributesManagerBl().setAttribute(sess, vo2, attribute);
//Prepare richAttribute with holders (attribute is not needed but holders are needed)
RichAttribute richAttr = new RichAttribute();
richAttr.setPrimaryHolder("String");
List<RichAttribute> listOfRichAttributes = perun.getAttributesManagerBl().getRichAttributesWithHoldersForAttributeDefinition(sess, new AttributeDefinition(attribute), richAttr);
//Return facilities Administrator too if exists
assertTrue("return at least 2 vos", listOfRichAttributes.size() > 1);
assertTrue("primary holder is type of vo", listOfRichAttributes.get(0).getPrimaryHolder() instanceof Vo);
assertTrue("secondary holder is null", listOfRichAttributes.get(0).getSecondaryHolder() == null);
List<Vo> returnedVos = new ArrayList<Vo>();
for (RichAttribute ra : listOfRichAttributes) {
returnedVos.add((Vo) ra.getPrimaryHolder());
}
assertTrue("returned vos contains vo2", returnedVos.contains(vo2));
assertTrue("returned vos contains vo1", returnedVos.contains(vo1));
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method deleteAttributeForce.
// FIXME - deleteAttributeForce - not yet implemented
@Ignore
@Test(expected = AttributeNotExistsException.class)
public void deleteAttributeForce() throws Exception {
System.out.println(CLASS_NAME + "deleteAttributeForce");
AttributeDefinition attrDef = new AttributeDefinition();
attrDef.setFriendlyName("attr-def-facility-tests-attr");
attrDef.setNamespace("urn:perun:facility:attribute-def:opt");
attrDef.setDescription("poznamka");
attrDef.setType(String.class.getName());
//
attributesManager.createAttribute(sess, attrDef);
assertNotNull("unable to create attribute before deletion", attributesManager.createAttribute(sess, attrDef));
attributesManager.deleteAttribute(sess, attrDef, true);
attributesManager.getAttributeDefinition(sess, "urn:perun:facility:attribute-def:opt:attr-def-facility-tests-attr");
// shouldn't find attribute definition in db
}
Aggregations