@Test
  public void test110ChangeModifyObject() throws Exception {
    final String TEST_NAME = "test110ChangeModifyObject";
    TestUtil.displayTestTile(this, TEST_NAME);

    OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME);

    Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith");

    Set<Operation> changes = new HashSet<Operation>();

    changes.add(createAddAttributeChange("employeeNumber", "123123123"));
    changes.add(createReplaceAttributeChange("sn", "Smith007"));
    changes.add(createAddAttributeChange("street", "Wall Street"));
    changes.add(createDeleteAttributeChange("givenName", "John"));

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findObjectClassDefinition(
            ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME);

    cc.modifyObject(accountDefinition, identifiers, changes, result);

    ResourceObjectIdentification identification =
        new ResourceObjectIdentification(accountDefinition, identifiers);
    PrismObject<ShadowType> shadow = cc.fetchObject(ShadowType.class, identification, null, result);
    ResourceAttributeContainer resObj = ShadowUtil.getAttributesContainer(shadow);

    AssertJUnit.assertNull(
        resObj.findAttribute(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "givenName")));

    String addedEmployeeNumber =
        resObj
            .findAttribute(
                new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "employeeNumber"))
            .getValue(String.class)
            .getValue();
    String changedSn =
        resObj
            .findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn"))
            .getValues(String.class)
            .iterator()
            .next()
            .getValue();
    String addedStreet =
        resObj
            .findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "street"))
            .getValues(String.class)
            .iterator()
            .next()
            .getValue();

    System.out.println("changed employee number: " + addedEmployeeNumber);
    System.out.println("changed sn: " + changedSn);
    System.out.println("added street: " + addedStreet);

    AssertJUnit.assertEquals("123123123", addedEmployeeNumber);
    AssertJUnit.assertEquals("Smith007", changedSn);
    AssertJUnit.assertEquals("Wall Street", addedStreet);
  }
示例#2
0
  // TODO - try to get rid of <br> attributes when creating new lines in association attributes
  // pop-up
  private String createAssociationTooltipText(PrismProperty property) {
    StringBuilder sb = new StringBuilder();
    sb.append(getString("prismValuePanel.message.association.attributes")).append("<br>");

    if (property.getParent() != null && property.getParent().getParent() != null) {
      PrismObject<ShadowType> shadowPrism =
          (PrismObject<ShadowType>) property.getParent().getParent();

      Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadowPrism);
      if (attributes == null || attributes.isEmpty()) {
        return sb.toString();
      }

      // TODO - this is a dirty fix for situation, when attribute value is too long and it is a
      // string without white chars,
      // thus it will not break in tooltip. break-all is also not good, since it can brake in the
      // middle of words. What we
      // are doing here is replacing every, with ,&#8203;, &#8203; (the same with @) is a zero-width
      // space, so the attribute value
      // will break after comma. This dirty fix will be removed when association editor is
      // completed.
      for (ResourceAttribute<?> attr : attributes) {
        for (Object realValue : attr.getRealValues()) {
          sb.append(getAttributeName(attr));
          sb.append(":");
          if (realValue != null) {
            sb.append(
                realValue
                    .toString()
                    .replace(",", ",&#8203;")
                    .replace("@", "@&#8203;")
                    .replace("_", "@&#8203;"));
          }
          sb.append("<br>");
        }
      }
    }

    return sb.toString();
  }