Search in sources :

Example 1 with F_TIMESTAMP

use of com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType.F_TIMESTAMP 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 2 with F_TIMESTAMP

use of com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType.F_TIMESTAMP in project midpoint by Evolveum.

the class QueryInterpreter2Test method test160QueryTrigger.

@Test
public void test160QueryTrigger() throws Exception {
    final Date NOW = new Date();
    Session session = open();
    try {
        XMLGregorianCalendar thisScanTimestamp = XmlTypeConverter.createXMLGregorianCalendar(NOW.getTime());
        ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, prismContext).item(ObjectType.F_TRIGGER, F_TIMESTAMP).le(thisScanTimestamp).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\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 3 with F_TIMESTAMP

use of com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType.F_TIMESTAMP in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method getObjectAuditRecords.

@NotNull
protected SearchResultList<AuditEventRecordType> getObjectAuditRecords(String oid) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
    Task task = createTask("getObjectAuditRecords");
    OperationResult result = task.getResult();
    return modelAuditService.searchObjects(prismContext.queryFor(AuditEventRecordType.class).item(AuditEventRecordType.F_TARGET_REF).ref(oid).asc(F_TIMESTAMP).build(), null, task, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with F_TIMESTAMP

use of com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType.F_TIMESTAMP in project midpoint by Evolveum.

the class QueryInterpreterTest method test088QueryTriggerBeforeAfter.

@Test
public void test088QueryTriggerBeforeAfter() 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 = prismContext.queryFor(ObjectType.class).exists(ObjectType.F_TRIGGER).block().item(F_TIMESTAMP).gt(lastScanTimestamp).and().item(F_TIMESTAMP).le(thisScanTimestamp).endBlock().build();
        String real = getInterpretedQuery(session, ObjectType.class, query);
        assertThat(real).isEqualToIgnoringWhitespace("select\n" + "  o.oid, o.fullObject\n" + "from\n" + "  RObject o\n" + "    left join o.trigger t\n" + "where\n" + "  ( t.timestamp > :timestamp and t.timestamp <= :timestamp2 )\n");
    } finally {
        close(session);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 5 with F_TIMESTAMP

use of com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType.F_TIMESTAMP in project midpoint by Evolveum.

the class QueryInterpreterTest method test086QueryTrigger.

@Test
public void test086QueryTrigger() throws Exception {
    final Date NOW = new Date();
    Session session = open();
    try {
        XMLGregorianCalendar thisScanTimestamp = XmlTypeConverter.createXMLGregorianCalendar(NOW.getTime());
        ObjectQuery query = prismContext.queryFor(ObjectType.class).item(ObjectType.F_TRIGGER, F_TIMESTAMP).le(thisScanTimestamp).build();
        String real = getInterpretedQuery(session, ObjectType.class, query);
        assertThat(real).isEqualToIgnoringWhitespace("select\n" + "  o.oid, o.fullObject\n" + "from\n" + "  RObject o\n" + "    left join o.trigger t\n" + "where\n" + "  t.timestamp <= :timestamp\n");
    } finally {
        close(session);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)4 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)4 Session (org.hibernate.Session)4 Test (org.testng.annotations.Test)4 Date (java.util.Date)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 AuditEventRecordType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType)1 NotNull (org.jetbrains.annotations.NotNull)1