コード例 #1
0
  //	@Test
  public void testDefinitionlessConstructionAndSchemaApplication() throws Exception {
    final String TEST_NAME = "testDefinitionlessConstructionAndSchemaApplication";
    PrismInternalTestUtil.displayTestTitle(TEST_NAME);

    // GIVEN
    // No context needed (yet)
    PrismObject<UserType> user = new PrismObject<UserType>(USER_QNAME, UserType.class);
    // Fill-in object values, no schema checking
    fillInUserDrake(user, false);
    // Make sure the object is OK
    PrismContext ctx = constructInitializedPrismContext();
    assertUserDrake(user, false, ctx);

    PrismObjectDefinition<UserType> userDefinition =
        getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user"));

    // WHEN
    user.applyDefinition(userDefinition);

    // THEN
    System.out.println("User:");
    System.out.println(user.debugDump());

    // Check schema now
    assertUserDrake(user, true, ctx);
  }
コード例 #2
0
  /**
   * Construct object without schema. Starts by creating object "out of the blue" and the working
   * downwards.
   */
  @Test(enabled = false) // definition-less containers are no longer supported
  public void testDefinitionlessConstruction() throws Exception {
    final String TEST_NAME = "testDefinitionlessConstruction";
    PrismInternalTestUtil.displayTestTitle(TEST_NAME);

    // GIVEN
    // No context needed

    // WHEN
    PrismObject<UserType> user = new PrismObject<UserType>(USER_QNAME, UserType.class);
    // Fill-in object values, no schema checking
    fillInUserDrake(user, false);

    // THEN
    System.out.println("User:");
    System.out.println(user.debugDump());
    // Check if the values are correct, no schema checking
    PrismContext ctx = constructInitializedPrismContext();
    assertUserDrake(user, false, ctx);
  }
コード例 #3
0
  /**
   * Construct object with schema. Starts by instantiating a definition and working downwards. All
   * the items in the object should have proper definition.
   */
  @Test
  public void testConstructionWithSchema() throws Exception {
    final String TEST_NAME = "testConstructionWithSchema";
    PrismInternalTestUtil.displayTestTitle(TEST_NAME);

    // GIVEN
    PrismContext ctx = constructInitializedPrismContext();
    PrismObjectDefinition<UserType> userDefinition =
        getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user"));

    // WHEN
    PrismObject<UserType> user = userDefinition.instantiate();
    // Fill-in object values, checking presence of definition while doing so
    fillInUserDrake(user, true);

    // THEN
    System.out.println("User:");
    System.out.println(user.debugDump());
    // Check if the values are correct, also checking definitions
    assertUserDrake(user, true, ctx);
  }
コード例 #4
0
  @Test
  public void testClone() throws Exception {
    final String TEST_NAME = "testClone";
    PrismInternalTestUtil.displayTestTitle(TEST_NAME);

    // GIVEN
    PrismContext ctx = constructInitializedPrismContext();
    PrismObjectDefinition<UserType> userDefinition =
        getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user"));
    PrismObject<UserType> user = userDefinition.instantiate();
    fillInUserDrake(user, true);
    // precondition
    assertUserDrake(user, true, ctx);

    // WHEN
    PrismObject<UserType> clone = user.clone();

    // THEN
    System.out.println("Cloned user:");
    System.out.println(clone.debugDump());
    // Check if the values are correct, also checking definitions
    assertUserDrake(clone, true, ctx);
  }