use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class EventExecServiceResolverTest method parseEventTest.
@Test
public void parseEventTest() throws ServiceNotExistsException, InvalidEventMessageException, InternalErrorException, PrivilegeException {
System.out.println("EventExecServiceResolver.parseEventTest()");
String message = member1.serializeToString() + " added to " + group1.serializeToString() + ".";
Event event = new Event();
event.setTimeStamp(System.currentTimeMillis());
event.setHeader("portishead");
event.setData(message);
Map<Facility, Set<ExecService>> resolvedServices = eventExecServiceResolver.parseEvent(event.toString());
Assert.assertTrue("We should resolved only one facility-service", resolvedServices.size() == 1);
Set<ExecService> resolved = resolvedServices.get(facility1);
Assert.assertTrue("We should have 2 exec services", resolved.size() == 2);
Assert.assertTrue("Our exec service 1 is missing", resolved.contains(execservice1));
Assert.assertTrue("Our exec service 2 is missing", resolved.contains(execservice2));
}
use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class urn_perun_member_resource_attribute_def_virt_isBannedTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_member_resource_attribute_def_virt_isBanned();
session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS);
facility = new Facility(1, "testFacility");
resource = new Resource(1, "testResource", "desc", 1, 1);
vo = new Vo(1, "testVo", "desc");
user = new User(1, "name", "surname", "middlename", "title", "title");
member = new Member(1, 1, 1, Status.VALID);
banOnResource = new BanOnResource(1, new Date(), "test", 1, 1);
banOnFacility = new BanOnFacility(1, new Date(), "test", 1, 1);
isBanned = new Attribute(classInstance.getAttributeDefinition());
isBanned.setValue(true);
message1 = "Ban " + banOnResource.serializeToString() + " was set for memberId 1 on resourceId 1";
message2 = "Ban " + banOnResource.serializeToString() + " was updated for memberId 1 on resourceId 1";
message3 = "Ban " + banOnResource.serializeToString() + " was removed for memberId 1 on resourceId 1";
message4 = "Ban " + banOnFacility.serializeToString() + " was set for userId 1 on facilityId 1";
message5 = "Ban " + banOnFacility.serializeToString() + " was updated for userId 1 on facilityId 1";
message6 = "Ban " + banOnFacility.serializeToString() + " was removed for userId 1 on facilityId 1";
wrongMessage = "Ban " + banOnFacility.serializeToString() + " was destroyed for userId 1 on facilityId 1";
}
use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_accountExpirationTimeTest method testCheckAttributeValue.
@Test
public void testCheckAttributeValue() throws Exception {
System.out.println("testCheckAttributeValue()");
attributeToCheck.setValue(1000);
when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Facility.class), anyString())).thenReturn(new Attribute() {
{
setValue(1500);
}
});
classInstance.checkAttributeValue(session, new Facility(), new User(), attributeToCheck);
}
use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_accountExpirationTimeTest method testCheckAttributeValueHigherValueThanFacilityTime.
@Test(expected = WrongAttributeValueException.class)
public void testCheckAttributeValueHigherValueThanFacilityTime() throws Exception {
System.out.println("testCheckAttributeValueHigherValueThanFacilityTime()");
attributeToCheck.setValue(1000);
when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Facility.class), anyString())).thenReturn(new Attribute() {
{
setValue(999);
}
});
classInstance.checkAttributeValue(session, new Facility(), new User(), attributeToCheck);
fail("Assigning lower accountExpirationTime than the time set at facility should throw exception.");
}
use of cz.metacentrum.perun.core.api.Facility 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);
}
Aggregations