use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class urn_perun_vo_attribute_def_def_toEmailTest method setUp.
@Before
public void setUp() {
classInstance = new urn_perun_vo_attribute_def_def_toEmail();
session = mock(PerunSessionImpl.class);
attributeToCheck = new Attribute();
vo = new Vo();
PerunBl perunBl = mock(PerunBl.class);
when(session.getPerunBl()).thenReturn(perunBl);
ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
when(perunBl.getModulesUtilsBl()).thenReturn(modulesUtilsBl);
when(session.getPerunBl().getModulesUtilsBl().isNameOfEmailValid(session, correctEmail)).thenReturn(true);
when(session.getPerunBl().getModulesUtilsBl().isNameOfEmailValid(session, incorrectEmail)).thenReturn(false);
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class ServicesManagerBlImplTest method setUp.
/*
* Tables with reference to service:
* - service_required_attrs
* - service_denials
* - resource_services
* - facility_service_destinations
* - service_service_packages
* - tasks
* - authz
*
*/
@Before
public void setUp() throws Exception {
perunSession = perun.getPerunSession(new PerunPrincipal("perunTests", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL), new PerunClient());
jdbcTemplate = new JdbcPerunTemplate(dataSource);
facility1 = new Facility();
facility2 = new Facility();
// Test Owner
int newOwnerId = Utils.getNewId(jdbcTemplate, "owners_id_seq");
testOwner = new Owner();
testOwner.setContact("Call me babe");
testOwner.setType(OwnerType.technical);
testOwner.setName("Tester-" + Long.toHexString(System.currentTimeMillis()));
testOwner.setId(newOwnerId);
jdbcTemplate.update("insert into owners(id, name, contact, type) values (?,?,?,?)", newOwnerId, testOwner.getName(), testOwner.getContact(), testOwner.getType().toString());
// Test Service #1
testService1 = new Service();
testService1.setName("Test_service_1_" + Long.toHexString(System.currentTimeMillis()));
testService1.setDelay(1);
testService1.setRecurrence(1);
testService1.setEnabled(true);
testService1.setScript("/hellish/test/script");
// Test Service #2
testService2 = new Service();
testService2.setName("Test_service_2_" + Long.toHexString(System.currentTimeMillis()));
testService2.setDelay(2);
testService2.setRecurrence(2);
testService2.setEnabled(true);
testService2.setScript("/hellish/test/script2");
testService1.setId(servicesManager.createService(perunSession, testService1).getId());
testService2.setId(servicesManager.createService(perunSession, testService2).getId());
// attribute
attribute = new AttributeDefinition();
attribute.setFriendlyName("ServicesManagerTestAttribute");
attribute.setDescription("TestingAttribute");
attribute.setNamespace(AttributesManager.NS_ENTITYLESS_ATTR_DEF);
attribute.setType(String.class.getName());
attribute = ((PerunBl) perun).getAttributesManagerBl().createAttribute(perunSession, attribute);
// required attributes
List<AttributeDefinition> attrlist = new ArrayList<>();
attrlist.add(attribute);
((PerunBl) perun).getServicesManagerBl().addRequiredAttributes(perunSession, testService1, attrlist);
//
// Testing Destination #1
testDestinationId1 = Utils.getNewId(jdbcTemplate, "destinations_id_seq");
jdbcTemplate.update("insert into destinations(id, destination, type) values (?,?,'host')", testDestinationId1, "test.destination." + testDestinationId1);
// Testing Destination #2
testDestinationId2 = Utils.getNewId(jdbcTemplate, "destinations_id_seq");
jdbcTemplate.update("insert into destinations(id, destination, type) values (?,?,'host')", testDestinationId2, "test.destination." + testDestinationId2);
// Testing Facility #1
testFacilityId1 = Utils.getNewId(jdbcTemplate, "facilities_id_seq");
jdbcTemplate.update("insert into facilities(id, name) values (?,?)", testFacilityId1, "Cluster_" + testFacilityId1);
facility1.setId(testFacilityId1);
// Testing Facility #2
testFacilityId2 = Utils.getNewId(jdbcTemplate, "facilities_id_seq");
jdbcTemplate.update("insert into facilities(id, name) values (?,?)", testFacilityId2, "Cluster_" + testFacilityId2);
facility2.setId(testFacilityId2);
// vo
vo = new Vo(0, "ServicesManagerTestVo", "RMTestVo");
vo = ((PerunBl) perun).getVosManagerBl().createVo(perunSession, vo);
// resource
resource = new Resource();
resource.setName("ServicesManagerTestResource");
resource.setDescription("Testovaci");
resource = ((PerunBl) perun).getResourcesManagerBl().createResource(perunSession, resource, vo, facility1);
// resource services
((PerunBl) perun).getResourcesManagerBl().assignService(perunSession, resource, testService1);
// facility_service_destinations
destination = ((PerunBl) perun).getServicesManagerBl().getDestinationById(perunSession, testDestinationId1);
((PerunBl) perun).getServicesManagerBl().addDestination(perunSession, testService1, facility1, destination);
// service package
servicesPackage = new ServicesPackage();
servicesPackage.setName("ResourcesManagertTestSP");
servicesPackage.setDescription("testingServicePackage");
servicesPackage = ((PerunBl) perun).getServicesManagerBl().createServicesPackage(perunSession, servicesPackage);
// service_service_packages
((PerunBl) perun).getServicesManagerBl().addServiceToServicesPackage(perunSession, servicesPackage, testService1);
// tasks
task = new Task();
task.setFacility(facility1);
task.setService(testService1);
task.setSchedule(0L);
task.setStatus(TaskStatus.DONE);
List<Destination> destinationsList = new ArrayList<>();
destinationsList.add(destination);
task.setDestinations(destinationsList);
((PerunBl) perun).getTasksManagerBl().insertTask(perunSession, task);
// authz
// authz entries for service are removed in ServicesManagerImpl::deleteService(),
// no point in testing here
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class urn_perun_group_attribute_def_def_fromEmailTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_group_attribute_def_def_fromEmail();
attributeToCheck = new Attribute(classInstance.getAttributeDefinition());
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
modulesUtilsBl = mock(ModulesUtilsBl.class);
when(perunBl.getModulesUtilsBl()).thenReturn(modulesUtilsBl);
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class urn_perun_group_attribute_def_def_groupStructureSynchronizationEnabledTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_group_attribute_def_def_groupStructureSynchronizationEnabled();
reqAttribute = new Attribute(classInstance.getAttributeDefinition());
attributeToCheck = new Attribute(classInstance.getAttributeDefinition());
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
when(sess.getPerunBl().getGroupsManagerBl().isGroupSynchronizedFromExternallSource(sess, group)).thenReturn(false);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPSYNCHROENABLED_ATTRNAME)).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPSQUERY_ATTRNAME)).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPMEMBERSQUERY_ATTRNAME)).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPEXTSOURCE_ATTRNAME)).thenReturn(reqAttribute);
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class urn_perun_group_attribute_def_def_groupSynchronizationTimesTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_group_attribute_def_def_groupSynchronizationTimes();
syncInterval = new Attribute(classInstance.getAttributeDefinition());
attributeToCheck = new Attribute(classInstance.getAttributeDefinition());
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
when(sess.getPerunBl().getGroupsManagerBl().isGroupSynchronizedFromExternallSource(sess, group)).thenReturn(false);
AttributesManagerBl attributesManagerBl;
attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPSYNCHROINTERVAL_ATTRNAME)).thenReturn(syncInterval);
}
Aggregations