private void dumpObject(StringBuilder sb, PrismObject<O> object, String label, int indent) { sb.append("\n"); DebugUtil.indentDebugDump(sb, indent); sb.append(label).append(":"); if (object == null) { sb.append(" null"); } else { sb.append("\n"); sb.append(object.debugDump(indent + 1)); } }
public static String dump(ObjectType object) { if (object == null) { return "null"; } return object.asPrismObject().debugDump(); }
public String debugDump(int indent, boolean expandObject) { StringBuilder sb = new StringBuilder(); DebugUtil.indentDebugDump(sb, indent); sb.append(toString()); if (expandObject && object != null) { sb.append("\n"); sb.append(object.debugDump(indent + 1)); } return sb.toString(); }
public static String debugDump(ObjectType objectType, int indent) { if (objectType == null) { StringBuilder sb = new StringBuilder(); DebugUtil.indentDebugDump(sb, indent); sb.append("null"); return sb.toString(); } return objectType.asPrismObject().debugDump(indent); }
protected void assertNoShadow(String username, PrismObject<ResourceType> resource, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { ObjectQuery query = createAccountShadowQuery(username, resource); List<PrismObject<ShadowType>> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); if (accounts.isEmpty()) { return; } LOGGER.error("Found shadow for "+username+" on "+resource+" while not expecting it:\n"+accounts.get(0).debugDump()); assert false : "Found shadow for "+username+" on "+resource+" while not expecting it: "+accounts; }
protected <T extends ObjectType> void assertObjectDoesntExist(Class<T> clazz, String oid) { OperationResult result = new OperationResult("assertObjectDoesntExist"); try { PrismObject<T> object = repositoryService.getObject(clazz, oid, null, result); fail("Object of type " + clazz.getName() + " with OID " + oid + " exists even if it shouldn't: " + object.debugDump()); } catch (ObjectNotFoundException e) { // ok } catch (SchemaException e) { throw new SystemException("Object of type " + clazz.getName() + " with OID " + oid + " probably exists, and moreover it couldn't be read: " + e.getMessage(), e); } }
@Override protected String getBody(Event event, GeneralNotifierType generalNotifierType, String transport, Task task, OperationResult result) throws SchemaException { String message = "Your accounts was successfully created. To activate your accounts, please click on the link bellow."; String accountsToActivate = "Shadow to be activated: \n"; for (ShadowType shadow : getShadowsToActivate((ModelEvent) event)) { accountsToActivate = accountsToActivate + shadow.asPrismObject().debugDump() + "\n"; } String body = message + "\n\n" + createConfirmationLink(getUser(event), generalNotifierType, result) + "\n\n" + accountsToActivate; return body; }
public static <O extends ObjectType> void logAdd(PrismObject<O> object, RepoAddOptions options, OperationResult subResult) { if (!LOGGER_OP.isDebugEnabled()) { return; } LOGGER_OP.debug("{} add {}{}: {}\n{}", PREFIX, object, shortDumpOptions(options), getStatus(subResult), object.debugDump(1)); }
private void single(final String TEST_NAME, File file, QName elementName) throws Exception { System.out.println("\n\n===[ "+TEST_NAME+" ]===\n"); // GIVEN PrismContext prismContext = getPrismContext(); // WHEN PrismObject<ObjectTemplateType> object = prismContext.parseObject(file); // THEN System.out.println("Parsed object:"); System.out.println(object.debugDump()); assertObjectTemplate(object, elementName); assertObjectTemplateInternals(object, elementName); }
@Test(enabled = false, expectedExceptions = SchemaException.class) public void test110ParseWrongNamespaceStrict() throws Exception { final String TEST_NAME = "test110ParseWrongNamespaceStrict"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN+THEN PrismObject<UserType> user = prismContext.parseObject(WRONG_NAMESPACE_FILE); System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); }
@Test public void testParsePasswordPolicyFile() throws Exception { System.out.println("===[ testParsePasswordPolicyFile ]==="); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN PrismObject<ValuePolicyType> policy = prismContext.parserFor(FILE).xml().parse(); // THEN System.out.println("Parsed policy:"); System.out.println(policy.debugDump()); assertPolicy(policy); }
@Test public void testParseTaskFile() throws Exception { System.out.println("===[ testParseTaskFile ]==="); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN PrismObject<TaskType> task = prismContext.parserFor(TASK_FILE).xml().parse(); // THEN System.out.println("Parsed task:"); System.out.println(task.debugDump()); assertTask(task); }
@Test public void testParseGenericFile() throws Exception { System.out.println("===[ testParseGenericFile ]==="); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN PrismObject<GenericObjectType> generic = prismContext.parserFor(GENERIC_FILE).xml().parse(); // THEN System.out.println("Parsed generic object:"); System.out.println(generic.debugDump()); assertGenericObject(generic); }
@Test public void testDiffSameValues() throws Exception { PrismObject<ResourceType> before = PrismTestUtil.parseObject(new File(TEST_DIR, "resource-white-before.xml")); PrismObject<ResourceType> after = PrismTestUtil.parseObject(new File(TEST_DIR, "resource-white-after.xml")); Collection<? extends ItemDelta> differences = before.diffModifications(after, EquivalenceStrategy.LITERAL_IGNORE_METADATA); assertEquals(1, differences.size()); System.out.println(differences.iterator().next().debugDump()); PrismObject<ResourceType> differencesApplied = before.clone(); ItemDeltaCollectionsUtil.applyTo(differences, differencesApplied); System.out.println(differencesApplied.debugDump()); assertEquals("'after' is different from the object with differences applied", after, differencesApplied); }
private PrismContainer<AssignmentType> parseUserAssignmentContainer() throws SchemaException, IOException { PrismContext prismContext = getPrismContext(); PrismObject<UserType> user = prismContext.parseObject(USER_FILE); System.out.println("Parsed user:"); System.out.println(user.debugDump()); return user.findContainer(ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_1_ID, AssignmentType.F_EXTENSION)); }
@Test public void testParseResourceFile() throws Exception { displayTestTitle("testParseResourceFile"); // GIVEN PrismContext prismContext = getPrismContext(); // WHEN PrismObject<ResourceType> resource = prismContext.parseObject(getFile(RESOURCE_FILE_BASENAME)); // THEN System.out.println("Parsed resource:"); System.out.println(resource.debugDump()); assertResource(resource, true, true, false); }
@Test public void testParseResourceFileSimple() throws Exception { displayTestTitle("testParseResourceFileSimple"); // GIVEN PrismContext prismContext = getPrismContext(); // WHEN PrismObject<ResourceType> resource = prismContext.parseObject(getFile(RESOURCE_FILE_SIMPLE_BASENAME)); // THEN System.out.println("Parsed resource:"); System.out.println(resource.debugDump()); assertResource(resource, true, true, true); }
private <O extends ObjectType> void serializationRoundTrip(File file) throws Exception { PrismContext prismContext = getPrismContext(); PrismObject<O> parsedObject = prismContext.parseObject(file); System.out.println("\nParsed object:"); System.out.println(parsedObject.debugDump()); serializationRoundTripPrismObject(parsedObject); serializationRoundTripObjectType(parsedObject.asObjectable()); }
@Test public void orgAssignmentSearchTestByOid() throws Exception { ObjectQuery query = prismContext.queryFor(UserType.class) .item(UserType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref("00000000-8888-6666-0000-100000000085") .build(); OperationResult result = new OperationResult("search"); List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result); result.recomputeStatus(); assertTrue(result.isSuccess()); assertEquals("Should find one user", 1, users.size()); assertEquals("Wrong user name", "atestuserX00002", users.get(0).getName().getOrig()); System.out.println("Found user:\n" + users.get(0).debugDump()); }
private <O extends ObjectType> void serializationRoundTripObjectType(O parsedObject) throws Exception { // WHEN String serializedObject = SerializationUtil.toString(parsedObject); // THEN O deserializedObject = SerializationUtil.fromString(serializedObject); deserializedObject.asPrismObject().revive(getPrismContext()); System.out.println("Deserialized object (ObjectType):"); System.out.println(deserializedObject.asPrismObject().debugDump()); ObjectDelta<O> diff = parsedObject.asPrismObject().diff((PrismObject) deserializedObject.asPrismObject()); assertTrue("Something changed in serializetion of "+parsedObject+" (ObjectType): "+diff, diff.isEmpty()); }