Search in sources :

Example 66 with Facility

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));
}
Also used : Set(java.util.Set) ExecService(cz.metacentrum.perun.taskslib.model.ExecService) Event(cz.metacentrum.perun.dispatcher.model.Event) Facility(cz.metacentrum.perun.core.api.Facility) AbstractDispatcherTest(cz.metacentrum.perun.dispatcher.AbstractDispatcherTest) Test(org.junit.Test)

Example 67 with Facility

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";
}
Also used : User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) Resource(cz.metacentrum.perun.core.api.Resource) Vo(cz.metacentrum.perun.core.api.Vo) Facility(cz.metacentrum.perun.core.api.Facility) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Member(cz.metacentrum.perun.core.api.Member) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) Date(java.util.Date) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) Before(org.junit.Before)

Example 68 with Facility

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);
}
Also used : PerunSession(cz.metacentrum.perun.core.api.PerunSession) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) Facility(cz.metacentrum.perun.core.api.Facility) Test(org.junit.Test)

Example 69 with Facility

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.");
}
Also used : PerunSession(cz.metacentrum.perun.core.api.PerunSession) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) Facility(cz.metacentrum.perun.core.api.Facility) Test(org.junit.Test)

Example 70 with Facility

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);
}
Also used : User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) Resource(cz.metacentrum.perun.core.api.Resource) Facility(cz.metacentrum.perun.core.api.Facility) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) Before(org.junit.Before)

Aggregations

Facility (cz.metacentrum.perun.core.api.Facility)188 Test (org.junit.Test)95 User (cz.metacentrum.perun.core.api.User)81 Attribute (cz.metacentrum.perun.core.api.Attribute)75 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)61 Resource (cz.metacentrum.perun.core.api.Resource)52 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)51 ArrayList (java.util.ArrayList)48 Group (cz.metacentrum.perun.core.api.Group)24 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)23 Member (cz.metacentrum.perun.core.api.Member)22 PerunSession (cz.metacentrum.perun.core.api.PerunSession)20 RichFacility (cz.metacentrum.perun.core.api.RichFacility)20 Host (cz.metacentrum.perun.core.api.Host)19 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)18 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)17 RichUser (cz.metacentrum.perun.core.api.RichUser)16 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)15 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)14 Vo (cz.metacentrum.perun.core.api.Vo)13