@Test
public void transformationToScriptFailure() {

	SysSystemDto system = createSystem();
	SysSchemaObjectClassDto objClass = createObjectClass(system);
	SysSchemaAttributeDto schemaAttr = createSchemaAttribute(objClass);
	SysSystemMappingDto systemMapping = testHelper.createMappingSystem(SystemEntityType.IDENTITY, objClass);
	SysSystemAttributeMappingDto attrMapping = createAttributeMappingSystem(systemMapping,
			AttributeMappingStrategyType.CREATE, schemaAttr.getId());
	
	// script consists of just one missing symbol,
	// which is supposed to be part of error message
	String script = "xxxxx";
	attrMapping.setTransformToResourceScript(script);
	systemMapping = mappingService.save(systemMapping);
	
	try {
		attributeMappingService.transformValueToResource(null, "testValue", attrMapping, new IdmIdentityDto());
		fail();
	} catch (ResultCodeException ex) {
		ErrorModel errModel = ex.getError().getError();
		String message = (String)errModel.getParameters().get(SysSystemAttributeMappingService.MAPPING_SCRIPT_FAIL_MESSAGE_KEY);
		String idmPath = (String)errModel.getParameters().get(SysSystemAttributeMappingService.MAPPING_SCRIPT_FAIL_IDM_PATH_KEY);
		assertEquals(errModel.getStatusEnum(), AccResultCode.GROOVY_SCRIPT_ATTR_TRANSFORMATION_FAILED.getCode());
		assertTrue(message.contains(script));
		assertTrue(idmPath.contains(system.getCode()));
		assertTrue(idmPath.contains(systemMapping.getName()));
		assertTrue(idmPath.contains(attrMapping.getName()));
	} catch (Exception e) {
		fail();
	}
}