use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_basicDefaultGIDTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_user_facility_attribute_def_def_basicDefaultGID();
session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS);
attrDef = session.getPerunBl().getAttributesManagerBl().getAttributeDefinition(session, AttributesManager.NS_USER_FACILITY_ATTR_DEF + "basicDefaultGID");
user = new User();
facility = new Facility(1, "testFa");
basic = new Attribute();
namespaceAttribute = new Attribute();
namespaceAttribute.setValue("test");
allowedResources = new ArrayList<>();
allowedResourcesWithSameGid = new ArrayList<>();
resource1 = new Resource(1, "test1", "desc", 1);
resource2 = new Resource(2, "test2", "desc", 1);
resource3 = new Resource(3, "test3", "desc", 1);
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_homeMountPointTest method SetUp.
@Before
public void SetUp() {
listOfMntPts = new Attribute();
classInstance = new urn_perun_user_facility_attribute_def_def_homeMountPoint();
session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS);
ArrayList<String> mntPts = new ArrayList<String>();
mntPts.add("/mnt/mnt1");
mntPts.add("/tmp/mnt2");
listOfMntPts.setValue(mntPts);
user = new User();
facility = new Facility();
resource = new Resource();
resource.setName("myResource");
resource.setDescription("desc");
resource1 = new Resource();
resource1.setId(1);
resource1.setName("myResource");
resource1.setDescription("desc");
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_homeMountPointTest method testFillAttributeOfUnknownUser.
/**
* Test of fillAttribute method, of class urn_perun_user_facility_attribute_def_def_homeMountPoint.
* with user who does not have an access at specified resource.
*/
@Test
public void testFillAttributeOfUnknownUser() throws Exception {
System.out.println("testFillAttributeOfUnknownUser()");
when(session.getPerunBl().getUsersManagerBl().getAllowedResources(any(PerunSession.class), any(Facility.class), any(User.class))).thenReturn(new ArrayList<Resource>());
when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), anyString())).thenReturn(listOfMntPts);
Attribute atr = classInstance.fillAttribute(session, facility, user, new AttributeDefinition());
assertNull("User's homeMountPoint was filled even they don't have an account there.", atr.getValue());
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_homeMountPointTest method testCheckAttributeValueWronghomeMountPointFormathomeMountPointIsDirectory.
@Test(expected = WrongAttributeValueException.class)
public void testCheckAttributeValueWronghomeMountPointFormathomeMountPointIsDirectory() throws Exception {
System.out.println("testCheckAttributeValueWronghomeMountPointFormathomeMountPointIsDirectory()");
when(session.getPerunBl().getUsersManagerBl().getAllowedResources(any(PerunSession.class), any(Facility.class), any(User.class))).thenReturn(new ArrayList<Resource>() {
{
add(resource);
}
});
when(session.getPerunBl().getFacilitiesManagerBl().getAssignedResources(any(PerunSession.class), any(Facility.class))).thenReturn(new ArrayList<Resource>() {
{
add(resource);
}
});
when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), anyString())).thenReturn(listOfMntPts);
Attribute attributeToCheck = new Attribute();
attributeToCheck.setValue("/mnt/mnt1/");
classInstance.checkAttributeValue(session, facility, user, attributeToCheck);
fail("Wrong homeMountPoint format should have thrown an exception");
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_homeMountPointTest method testFillAttribute.
/**
* Test of fillAttribute method, of class urn_perun_user_facility_attribute_def_def_homeMountPoint.
* with all parameters properly set.
*/
@Test
public void testFillAttribute() throws Exception {
System.out.println("testFillAttribute()");
when(session.getPerunBl().getUsersManagerBl().getAllowedResources(any(PerunSession.class), any(Facility.class), any(User.class))).thenReturn(new ArrayList<Resource>() {
{
add(resource);
}
});
when(session.getPerunBl().getFacilitiesManagerBl().getAssignedResources(any(PerunSession.class), any(Facility.class))).thenReturn(new ArrayList<Resource>() {
{
add(resource);
}
});
when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), anyString())).thenReturn(listOfMntPts);
Attribute filledAttribute = classInstance.fillAttribute(session, facility, user, new AttributeDefinition());
assertTrue("A different homeMountPoint was filled than those available", (listOfMntPts.getValue()).equals(filledAttribute.getValue()));
}
Aggregations