use of cz.metacentrum.perun.taskslib.model.ExecService 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.taskslib.model.ExecService in project perun by CESNET.
the class ExecServiceDaoTest method testRemoveExecService.
@Test
public void testRemoveExecService() {
System.out.println("ExecServiceDao.removeExecService");
try {
log.debug("testRemoveExecService: Inserting execServices...");
// Test ExecService #1 (Parent:testService1)
ExecService execService = new ExecService();
execService.setDefaultDelay(1);
execService.setDefaultRecurrence(1);
execService.setEnabled(true);
execService.setService(testService1);
execService.setScript("/hellish/test/script");
execService.setExecServiceType(ExecServiceType.GENERATE);
execService.setId(execServiceDao.insertExecService(execService));
// Test ExecService #2 (Parent:testService1)
ExecService execService2 = new ExecService();
execService2.setDefaultDelay(2);
execService2.setDefaultRecurrence(2);
execService2.setEnabled(true);
execService2.setService(testService1);
execService2.setScript("/hellish/test/script2");
execService2.setExecServiceType(ExecServiceType.SEND);
execService2.setId(execServiceDao.insertExecService(execService2));
// Test ExecService #3 (Parent:testService2)
ExecService execService3 = new ExecService();
execService3.setDefaultDelay(3);
execService3.setDefaultRecurrence(3);
execService3.setEnabled(true);
execService3.setService(testService2);
execService3.setScript("/hellish/test/script3");
execService3.setExecServiceType(ExecServiceType.SEND);
execService3.setId(execServiceDao.insertExecService(execService3));
log.debug("testRemoveExecService: Deleting one of the execExecServices...");
ExecService execServiceToBeDeleted = execServiceDao.getExecService(execService2.getId());
execServiceDao.deleteExecService(execServiceToBeDeleted.getId());
assertEquals(execServiceDao.getExecService(execService.getId()), execService);
assertEquals(execServiceDao.getExecService(execService2.getId()), null);
assertEquals(execServiceDao.getExecService(execService3.getId()), execService3);
} catch (Exception e) {
log.error(e.getMessage(), e);
fail();
}
}
use of cz.metacentrum.perun.taskslib.model.ExecService in project perun by CESNET.
the class ExecServiceDaoTest method testUpdateExecService.
@Test
public void testUpdateExecService() {
System.out.println("ExecServiceDao.updateExecService");
try {
log.debug("testUpdateExecService: Inserting execExecService...");
// Test ExecService #1 (Parent:testService1)
ExecService execService = new ExecService();
execService.setDefaultDelay(1);
execService.setDefaultRecurrence(1);
execService.setEnabled(true);
execService.setService(testService1);
execService.setScript("/hellish/test/script");
execService.setExecServiceType(ExecServiceType.GENERATE);
execService.setId(execServiceDao.insertExecService(execService));
log.debug("testUpdateExecService: Updating execService...");
execService.setDefaultDelay(2);
execService.setDefaultRecurrence(2);
execService.setEnabled(true);
execService.setScript("/hellish/test/script2");
execService.setExecServiceType(ExecServiceType.GENERATE);
execServiceDao.updateExecService(execService);
ExecService retrievedExecService = execServiceDao.getExecService(execService.getId());
assertEquals(retrievedExecService.getDefaultDelay(), execService.getDefaultDelay());
assertEquals(retrievedExecService.getDefaultRecurrence(), execService.getDefaultRecurrence());
assertEquals(retrievedExecService.getScript(), execService.getScript());
assertEquals(retrievedExecService.getExecServiceType(), execService.getExecServiceType());
} catch (Exception e) {
log.error(e.getMessage(), e);
fail();
}
}
use of cz.metacentrum.perun.taskslib.model.ExecService in project perun by CESNET.
the class ExecServiceDaoTest method testListExecServices.
@Test
public void testListExecServices() {
System.out.println("ExecServiceDao.listExecServices");
try {
log.debug("testListExecServices: Inserting execServices...");
int originalNumberOfExecServices = execServiceDao.countExecServices();
// Test ExecService #1 (Parent:testService1)
ExecService execService = new ExecService();
execService.setDefaultDelay(1);
execService.setDefaultRecurrence(1);
execService.setEnabled(true);
execService.setService(testService1);
execService.setScript("/hellish/test/script");
execService.setExecServiceType(ExecServiceType.GENERATE);
execServiceDao.insertExecService(execService);
// Test ExecService #2 (Parent:testService1)
ExecService execService2 = new ExecService();
execService2.setDefaultDelay(2);
execService2.setDefaultRecurrence(2);
execService2.setEnabled(true);
execService2.setService(testService1);
execService2.setScript("/hellish/test/script2");
execService2.setExecServiceType(ExecServiceType.SEND);
execServiceDao.insertExecService(execService2);
// Test ExecService #3 (Parent:testService2)
ExecService execService3 = new ExecService();
execService3.setDefaultDelay(3);
execService3.setDefaultRecurrence(3);
execService3.setEnabled(true);
execService3.setService(testService2);
execService3.setScript("/hellish/test/script3");
execService3.setExecServiceType(ExecServiceType.SEND);
execServiceDao.insertExecService(execService3);
log.debug("testListExecServices: Retrieving all execExecServices...");
List<ExecService> execServices = execServiceDao.listExecServices();
assertNotNull(execServices);
for (ExecService s : execServices) {
log.debug("\tID:" + s.getId());
log.debug("\tDefDELAY:" + s.getDefaultDelay());
log.debug("\tDefRecurrence:" + s.getDefaultRecurrence());
log.debug("\tENABLED:" + s.isEnabled());
log.debug("\tSERVICE:" + s.getService().getName());
log.debug("\tSCRIPT:" + s.getScript());
log.debug("\tTYPE:" + s.getExecServiceType().toString());
}
assertEquals(execServices.size(), originalNumberOfExecServices + 3);
} catch (Exception e) {
log.error("testListExecServices: " + e.getMessage(), e);
fail();
}
}
use of cz.metacentrum.perun.taskslib.model.ExecService in project perun by CESNET.
the class ExecServiceDenialDaoTest method testListDenialsForDestination.
@Test
public void testListDenialsForDestination() {
System.out.println("ExecServiceDenialDao.listDenialsForDestination");
try {
log.debug("testListDenialsForDestination: Inserting a new denial...");
execServiceDenialDao.banExecServiceOnDestination(testExecService1.getId(), testDestinationId1);
execServiceDenialDao.banExecServiceOnDestination(testExecService2.getId(), testDestinationId1);
log.debug("testListDenialsForDestination: Listing all denials (denied services) for the destination...");
List<ExecService> deniedExecServices = execServiceDenialDao.listDenialsForDestination(testDestinationId1);
assertNotNull(deniedExecServices);
for (ExecService deniedExecService : deniedExecServices) {
log.debug("\tDESTINATION:" + testDestinationId1);
log.debug("\tID:" + deniedExecService.getId());
log.debug("\tDefDELAY:" + deniedExecService.getDefaultDelay());
log.debug("\tDefRecurrence:" + deniedExecService.getDefaultRecurrence());
log.debug("\tENABLED:" + deniedExecService.isEnabled());
log.debug("\tService:" + deniedExecService.getService().getName());
log.debug("\tSCRIPT:" + deniedExecService.getScript());
log.debug("\tTYPE:" + deniedExecService.getExecServiceType().toString());
}
assertEquals(deniedExecServices.size(), 2);
assertEquals(execServiceDenialDao.listDenialsForDestination(testDestinationId2).size(), 0);
} catch (Exception e) {
log.error(e.getMessage(), e);
fail();
}
}
Aggregations