use of eu.bcvsolutions.idm.core.api.dto.IdmScriptDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmScriptServiceIntegrationTest method tryRedeployScript.
@Test
public void tryRedeployScript() {
configurationService.setValue(Recoverable.BACKUP_FOLDER_CONFIG, TEST_BACKUP_FOLDER);
IdmScriptDto script1 = scriptService.getByCode(TEST_SCRIPT_CODE_1);
assertNotNull(script1);
assertEquals(TEST_SCRIPT_NAME_1, script1.getName());
String changeName = "test_change_" + System.currentTimeMillis();
script1.setName(changeName);
script1 = scriptService.save(script1);
assertEquals(changeName, script1.getName());
try {
script1 = scriptService.redeploy(script1);
assertEquals(TEST_SCRIPT_NAME_1, script1.getName());
} catch (ResultCodeException e) {
fail();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmScriptDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmScriptServiceIntegrationTest method initFromMultipleLocations.
@Test
public void initFromMultipleLocations() {
IdmScriptDto script3 = scriptService.getByCode(TEST_SCRIPT_CODE_3);
IdmScriptDto scriptOverride = scriptService.getByCode(TEST_SCRIPT_CODE_OVERRIDE);
assertNotNull(script3);
assertNotNull(scriptOverride);
assertEquals(TEST_SCRIPT_CODE_3, script3.getCode());
assertEquals(TEST_SCRIPT_CODE_OVERRIDE, scriptOverride.getCode());
//
assertEquals("String overrideUpdate;", scriptOverride.getScript().trim());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmScriptDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmScriptServiceIntegrationTest method tryRedeployMissingScript.
@Test
public void tryRedeployMissingScript() {
IdmScriptDto script = new IdmScriptDto();
script.setCategory(IdmScriptCategory.SYSTEM);
script.setCode("test_" + System.currentTimeMillis());
script.setName("test_" + System.currentTimeMillis());
script = scriptService.save(script);
assertNotNull(script);
assertNotNull(script.getId());
try {
scriptService.redeploy(script);
fail();
} catch (ResultCodeException e) {
ResultCodeException resultCode = (ResultCodeException) e;
assertEquals(resultCode.getError().getError().getStatusEnum(), CoreResultCode.SCRIPT_XML_FILE_NOT_FOUND.name());
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmScriptDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmScriptServiceIntegrationTest method backupMissingFolderNewEntity.
@Test
public void backupMissingFolderNewEntity() {
configurationService.setValue(Recoverable.BACKUP_FOLDER_CONFIG, null);
IdmScriptDto script = new IdmScriptDto();
script.setCategory(IdmScriptCategory.SYSTEM);
script.setCode("test_" + System.currentTimeMillis());
script.setName("test_" + System.currentTimeMillis());
script = scriptService.save(script);
assertNotNull(script);
assertNotNull(script.getId());
try {
scriptService.backup(script);
fail();
} catch (ResultCodeException e) {
ResultCodeException resultCode = (ResultCodeException) e;
assertEquals(resultCode.getError().getError().getStatusEnum(), CoreResultCode.BACKUP_FOLDER_NOT_FOUND.name());
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmScriptDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmScriptServiceIntegrationTest method tryBackup.
@Test
public void tryBackup() {
File directory = new File(TEST_BACKUP_FOLDER);
if (directory.exists() && directory.isDirectory()) {
try {
FileUtils.deleteDirectory(directory);
} catch (IOException e) {
fail();
}
}
//
IdmScriptDto script1 = scriptService.getByCode(TEST_SCRIPT_CODE_1);
assertNotNull(script1);
configurationService.setValue(Recoverable.BACKUP_FOLDER_CONFIG, TEST_BACKUP_FOLDER);
//
try {
IdmScriptDto newDto = scriptService.redeploy(script1);
assertEquals(script1.getCode(), newDto.getCode());
//
DateTime date = new DateTime();
DecimalFormat decimalFormat = new DecimalFormat("00");
directory = new File(TEST_BACKUP_FOLDER + "scripts/" + date.getYear() + decimalFormat.format(date.getMonthOfYear()) + decimalFormat.format(date.getDayOfMonth()) + "/");
File[] files = directory.listFiles();
assertEquals(1, files.length);
File backup = files[0];
assertTrue(backup.exists());
assertTrue(backup.getName().contains("admin"));
assertTrue(backup.getName().contains(script1.getCode()));
} catch (Exception e) {
fail();
}
}
Aggregations