use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class TestMappingTime method testSetReferenceTimeBefore.
@Test
public void testSetReferenceTimeBefore() throws Exception {
final String TEST_NAME = "testSetReferenceTimeBefore";
System.out.println("===[ " + TEST_NAME + "]===");
// GIVEN
PrismObject<UserType> userOld = evaluator.getUserOld();
XMLGregorianCalendar disableTimestamp = userOld.asObjectable().getActivation().getDisableTimestamp();
userOld.asObjectable().getActivation().setDisableTimestamp(null);
ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, new ItemPath(UserType.F_ACTIVATION, ActivationType.F_DISABLE_TIMESTAMP), evaluator.getPrismContext(), disableTimestamp);
Mapping.Builder<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> builder = evaluator.createMappingBuilder(MAPPING_TIME_ACTIVATION, TEST_NAME, "title", delta, userOld);
builder.setNow(TIME_PAST);
PrismPropertyDefinition<Boolean> existenceDef = new PrismPropertyDefinitionImpl<>(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN, evaluator.getPrismContext());
builder.setDefaultTargetDefinition(existenceDef);
Mapping<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> mapping = builder.build();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = mapping.getOutputTriple();
assertNullTriple(outputTriple);
assertNextRecompute(mapping, TIME_MAPPING_DISABLED_PLUS_1M);
}
use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class TestDelta method createDeltaForFindItem.
private ObjectDelta<UserType> createDeltaForFindItem() throws SchemaException {
ObjectDelta<UserType> userDelta = ObjectDelta.createModificationAddProperty(UserType.class, USER_FOO_OID, UserType.F_LOCALITY, PrismTestUtil.getPrismContext(), "Caribbean");
userDelta.addModificationReplaceProperty(UserType.F_GIVEN_NAME, "Guybrush");
ContainerDelta<ActivationType> activationDelta = userDelta.createContainerModification(new ItemPath(UserType.F_ACTIVATION));
PrismContainerValue<ActivationType> activationCVal = new PrismContainerValue();
activationDelta.addValueToAdd(activationCVal);
PrismProperty<Boolean> enabledProperty = activationCVal.createProperty(ActivationType.F_ENABLED);
enabledProperty.setRealValue(Boolean.TRUE);
PrismProperty<XMLGregorianCalendar> validFromProperty = activationCVal.createProperty(ActivationType.F_VALID_FROM);
validFromProperty.setRealValue(XmlTypeConverter.createXMLGregorianCalendar(20016, 5, 16, 19, 8, 33));
userDelta.addModification(activationDelta);
return userDelta;
}
use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class TestTypeConversion method testJavaStringToXMLGregorianCalendar.
@Test
public void testJavaStringToXMLGregorianCalendar() throws Exception {
String stringDate = "1975-05-30T21:30:00.000Z";
// WHEN
XMLGregorianCalendar xmlGregorianCalendar = JavaTypeConverter.convert(XMLGregorianCalendar.class, stringDate);
// THEN
XMLGregorianCalendar expectedCal = XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0);
PrismAsserts.assertEquals("Wrong java value", expectedCal, xmlGregorianCalendar);
}
use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class TestExpressionFunctions method testParseDateTime.
@Test
public void testParseDateTime() throws Exception {
final String TEST_NAME = "testParseDateTime";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
BasicExpressionFunctions f = createBasicFunctions();
// WHEN
XMLGregorianCalendar resultValue = f.parseDateTime("yyyy MM dd HH:mm:ss.SSS zzzz", "1975 05 30 22:30:00.000 Central European Time");
// THEN
assertNotNull("Result value is null", resultValue);
System.out.println("Resulting value: " + resultValue);
XMLGregorianCalendar xmlCal = XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0);
assertEquals("Wrong result value", xmlCal, resultValue);
}
use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class TriggerScannerTaskHandler method fireTriggers.
private void fireTriggers(AbstractScannerResultHandler<ObjectType> handler, PrismObject<ObjectType> object, Task workerTask, Task coordinatorTask, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ObjectAlreadyExistsException, ConfigurationException, PolicyViolationException, SecurityViolationException {
PrismContainer<TriggerType> triggerContainer = object.findContainer(F_TRIGGER);
if (triggerContainer == null) {
LOGGER.warn("Strange thing, attempt to fire triggers on {}, but it does not have trigger container", object);
} else {
List<PrismContainerValue<TriggerType>> triggerCVals = triggerContainer.getValues();
if (triggerCVals.isEmpty()) {
LOGGER.warn("Strange thing, attempt to fire triggers on {}, but it does not have any triggers in trigger container", object);
} else {
LOGGER.trace("Firing triggers for {} ({} triggers)", object, triggerCVals.size());
List<TriggerType> triggers = getSortedTriggers(triggerCVals);
for (TriggerType trigger : triggers) {
XMLGregorianCalendar timestamp = trigger.getTimestamp();
if (timestamp == null) {
LOGGER.warn("Trigger without a timestamp in {}", object);
} else {
if (isHot(handler, timestamp)) {
fireTrigger(trigger, object, triggerContainer.getDefinition(), workerTask, coordinatorTask, result);
} else {
LOGGER.trace("Trigger {} is not hot (timestamp={}, thisScanTimestamp={}, lastScanTimestamp={})", trigger, timestamp, handler.getThisScanTimestamp(), handler.getLastScanTimestamp());
}
}
}
}
}
}
Aggregations