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();
}
}
use of cz.metacentrum.perun.taskslib.model.ExecService in project perun by CESNET.
the class ExecServiceDenialDaoTest method setUp.
@Before
public void setUp() throws InternalErrorException, OwnerNotExistsException, ServiceExistsException, PrivilegeException {
perunSession = perun.getPerunSession(new PerunPrincipal("perunTests", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL), new PerunClient());
jdbcTemplate = new JdbcPerunTemplate(dataSource);
// 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()));
// Test Service #2
testService2 = new Service();
testService2.setName("Test_service_2_" + Long.toHexString(System.currentTimeMillis()));
testService1.setId(servicesManager.createService(perunSession, testService1).getId());
testService2.setId(servicesManager.createService(perunSession, testService2).getId());
// 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);
// Testing Facility #2
testFacilityId2 = Utils.getNewId(jdbcTemplate, "facilities_id_seq");
jdbcTemplate.update("insert into facilities(id, name) values (?,?)", testFacilityId2, "Cluster_" + testFacilityId2);
// Test ExecService #1 (Parent:testService1)
testExecService1 = new ExecService();
testExecService1.setDefaultDelay(1);
testExecService1.setDefaultRecurrence(1);
testExecService1.setEnabled(true);
testExecService1.setService(testService1);
testExecService1.setScript("/hellish/test/script");
testExecService1.setExecServiceType(ExecServiceType.GENERATE);
try {
testExecService1.setId(execServiceDao.insertExecService(testExecService1));
} catch (InternalErrorException e) {
log.error(e.toString(), e);
}
// Test ExecService #2 (Parent:testService1)
testExecService2 = new ExecService();
testExecService2.setDefaultDelay(2);
testExecService2.setDefaultRecurrence(2);
testExecService2.setEnabled(true);
testExecService2.setService(testService2);
testExecService2.setScript("/hellish/test/script2");
testExecService2.setExecServiceType(ExecServiceType.SEND);
try {
testExecService2.setId(execServiceDao.insertExecService(testExecService2));
} catch (InternalErrorException e) {
log.error(e.toString(), e);
}
}
Aggregations