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);
}
}
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);
}
}
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);
}
}
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;
}
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);
}
Aggregations