Search in sources :

Example 26 with XMLGregorianCalendar

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);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 27 with XMLGregorianCalendar

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;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ActivationType(com.evolveum.midpoint.prism.foo.ActivationType) UserType(com.evolveum.midpoint.prism.foo.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 28 with XMLGregorianCalendar

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);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Test(org.testng.annotations.Test)

Example 29 with 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);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 30 with XMLGregorianCalendar

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());
                    }
                }
            }
        }
    }
}
Also used : TriggerType(com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue)

Aggregations

XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)336 Test (org.testng.annotations.Test)159 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)130 Task (com.evolveum.midpoint.task.api.Task)104 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)72 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)52 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)44 Date (java.util.Date)36 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)32 ArrayList (java.util.ArrayList)32 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)31 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)31 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)30 AbstractSynchronizationStoryTest (com.evolveum.midpoint.model.intest.sync.AbstractSynchronizationStoryTest)23 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 GregorianCalendar (java.util.GregorianCalendar)18 QName (javax.xml.namespace.QName)18 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)15 Duration (javax.xml.datatype.Duration)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)14