Search in sources :

Example 96 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class QueryInterpreter2Test method test560queryMetadataTimestamp.

@Test
public void test560queryMetadataTimestamp() throws Exception {
    Session session = open();
    try {
        XMLGregorianCalendar timeXml = XMLGregorianCalendarType.asXMLGregorianCalendar(new Date());
        ObjectQuery query = QueryBuilder.queryFor(ReportOutputType.class, prismContext).item(ReportOutputType.F_METADATA, MetadataType.F_CREATE_TIMESTAMP).le(timeXml).build();
        String real = getInterpretedQuery2(session, ReportOutputType.class, query);
        String expected = "select\n" + "  r.oid, r.fullObject,\n" + "  r.stringsCount,\n" + "  r.longsCount,\n" + "  r.datesCount,\n" + "  r.referencesCount,\n" + "  r.polysCount,\n" + "  r.booleansCount\n" + "from\n" + "  RReportOutput r\n" + "where\n" + "  r.createTimestamp <= :createTimestamp";
        assertEqualsIgnoreWhitespace(expected, real);
    } finally {
        close(session);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Date(java.util.Date) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 97 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class QueryInterpreter2Test method test410ActivationQueryWrong.

@Test
public void test410ActivationQueryWrong() throws Exception {
    XMLGregorianCalendar lastScanTimestamp = XMLGregorianCalendarType.asXMLGregorianCalendar(new Date());
    XMLGregorianCalendar thisScanTimestamp = XMLGregorianCalendarType.asXMLGregorianCalendar(new Date());
    ObjectQuery query = QueryBuilder.queryFor(FocusType.class, prismContext).block().item(FocusType.F_ACTIVATION, ActivationType.F_VALID_FROM).gt(lastScanTimestamp).and().item(FocusType.F_ACTIVATION, ActivationType.F_VALID_FROM).le(thisScanTimestamp).endBlock().or().block().item(FocusType.F_ACTIVATION, ActivationType.F_VALID_TO).gt(lastScanTimestamp).and().item(FocusType.F_ACTIVATION, ActivationType.F_VALID_TO).le(thisScanTimestamp).endBlock().or().block().item(F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_FROM).gt(lastScanTimestamp).and().item(F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_FROM).le(thisScanTimestamp).endBlock().or().block().item(F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO).gt(lastScanTimestamp).and().item(F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO).le(thisScanTimestamp).endBlock().build();
    Session session = open();
    try {
        String real = getInterpretedQuery2(session, UserType.class, query, false);
        String expected = "select\n" + "  u.oid, u.fullObject,\n" + "  u.stringsCount,\n" + "  u.longsCount,\n" + "  u.datesCount,\n" + "  u.referencesCount,\n" + "  u.polysCount,\n" + "  u.booleansCount\n" + "from\n" + "  RUser u\n" + "    left join u.assignments a with a.assignmentOwner = :assignmentOwner\n" + "    left join u.assignments a2 with a2.assignmentOwner = :assignmentOwner2\n" + "    left join u.assignments a3 with a3.assignmentOwner = :assignmentOwner3\n" + "    left join u.assignments a4 with a4.assignmentOwner = :assignmentOwner4\n" + "where\n" + "  (\n" + "    (\n" + "      u.activation.validFrom > :validFrom and\n" + "      u.activation.validFrom <= :validFrom2\n" + "    ) or\n" + "    (\n" + "      u.activation.validTo > :validTo and\n" + "      u.activation.validTo <= :validTo2\n" + "    ) or\n" + "    (\n" + "      a.activation.validFrom > :validFrom3 and\n" + "      a2.activation.validFrom <= :validFrom4\n" + "    ) or\n" + "    (\n" + "      a3.activation.validTo > :validTo3 and\n" + "      a4.activation.validTo <= :validTo4\n" + "    )\n" + "  )\n";
        assertEqualsIgnoreWhitespace(expected, real);
    } finally {
        close(session);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Date(java.util.Date) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 98 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class QueryInterpreter2Test method test162QueryTriggerBeforeAfter.

@Test
public void test162QueryTriggerBeforeAfter() throws Exception {
    final Date NOW = new Date();
    Session session = open();
    try {
        XMLGregorianCalendar lastScanTimestamp = XmlTypeConverter.createXMLGregorianCalendar(NOW.getTime());
        XMLGregorianCalendar thisScanTimestamp = XmlTypeConverter.createXMLGregorianCalendar(NOW.getTime());
        ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, prismContext).exists(ObjectType.F_TRIGGER).block().item(F_TIMESTAMP).gt(lastScanTimestamp).and().item(F_TIMESTAMP).le(thisScanTimestamp).endBlock().build();
        String real = getInterpretedQuery2(session, ObjectType.class, query);
        String expected = "select\n" + "  o.oid, o.fullObject, o.stringsCount, o.longsCount, o.datesCount, o.referencesCount, o.polysCount, o.booleansCount\n" + "from\n" + "  RObject o\n" + "    left join o.trigger t\n" + "where\n" + "  ( t.timestamp > :timestamp and t.timestamp <= :timestamp2 )\n";
        assertEqualsIgnoreWhitespace(expected, real);
    } finally {
        close(session);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Date(java.util.Date) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 99 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class RLookupTableRow method toRepo.

private static RLookupTableRow toRepo(LookupTableRowType row) throws SchemaException {
    RLookupTableRow rRow = new RLookupTableRow();
    rRow.setId(RUtil.toInteger(row.getId()));
    if (row.getKey() == null) {
        throw new SchemaException("Attempt to insert a row with no key");
    }
    rRow.setKey(row.getKey());
    rRow.setLabel(RPolyString.copyFromJAXB(row.getLabel()));
    rRow.setLastChangeTimestamp(row.getLastChangeTimestamp());
    if (rRow.getLastChangeTimestamp() == null) {
        XMLGregorianCalendar cal = XMLGregorianCalendarType.asXMLGregorianCalendar(new Date());
        rRow.setLastChangeTimestamp(cal);
        row.setLastChangeTimestamp(cal);
    }
    rRow.setValue(row.getValue());
    return rRow;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Date(java.util.Date)

Example 100 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class TestAbstractAuthenticationEvaluator method test101PasswordLoginBadPasswordJack.

@Test
public void test101PasswordLoginBadPasswordJack() throws Exception {
    final String TEST_NAME = "test101PasswordLoginBadPasswordJack";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    ConnectionEnvironment connEnv = createConnectionEnvironment();
    XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
    try {
        // WHEN
        TestUtil.displayWhen(TEST_NAME);
        getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getBadPasswordJack()));
        AssertJUnit.fail("Unexpected success");
    } catch (BadCredentialsException e) {
        // This is expected
        // THEN
        TestUtil.displayThen(TEST_NAME);
        display("expected exception", e);
        assertBadPasswordException(e, USER_JACK_USERNAME);
    }
    XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    display("user after", userAfter);
    assertFailedLogins(userAfter, 1);
    assertUserLockout(userAfter, LockoutStatusType.NORMAL);
    assertLastFailedLogin(userAfter, startTs, endTs);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) BadCredentialsException(org.springframework.security.authentication.BadCredentialsException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

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