@SafeVarargs public static <T> void assertSets(String message, MatchingRule<T> matchingRule, Collection<T> actualValues, T... expectedValues) throws SchemaException { assertSets(message, matchingRule, actualValues, Arrays.asList(expectedValues)); }
protected <T> void assertAttribute(PrismObject<ResourceType> resource, ShadowType shadow, QName attrQname, T... expectedValues) { List<T> actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, actualValues, expectedValues); }
protected <T> void assertAttribute(PrismObject<ResourceType> resource, ShadowType shadow, QName attrQname, T... expectedValues) { List<T> actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, actualValues, expectedValues); }
public static <T> void assertSets(String message, Collection<T> actualValues, Collection<T> expectedValues) { try { assertSets(message, null, actualValues, expectedValues); } catch (SchemaException e) { // no matching rule. should not happen throw new IllegalStateException(e.getMessage(), e); } }
public static <F extends FocusType> void assertAssignedTargets(PrismObject<F> user, String typeDesc, QName type, String... expectedTargetOids) { List<String> haveTagetOids = getAssignedOids(user, type); PrismAsserts.assertSets("Wrong "+typeDesc+" in "+user, haveTagetOids, expectedTargetOids); }
protected <T> void assertAttribute(PrismObject<ResourceType> resource, ShadowType shadow, MatchingRule<T> matchingRule, QName attrQname, T... expectedValues) throws SchemaException { List<T> actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, matchingRule, actualValues, expectedValues); }
protected <T> void assertAttribute(PrismObject<ResourceType> resource, ShadowType shadow, MatchingRule<T> matchingRule, QName attrQname, T... expectedValues) throws SchemaException { List<T> actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, matchingRule, actualValues, expectedValues); }
@SafeVarargs public static <T> void assertSets(String message, Collection<T> actualValues, T... expectedValues) { try { assertSets(message, null, actualValues, expectedValues); } catch (SchemaException e) { // no matching rule. should not happen throw new IllegalStateException(e.getMessage(), e); } }
public static <F extends FocusType> void assertAssignedTargets(PrismObject<F> user, String typeDesc, QName type, Collection<String> expectedTargetOids) { List<String> haveTagetOids = getAssignedOids(user, type); PrismAsserts.assertSets("Wrong "+typeDesc+" in "+user, haveTagetOids, expectedTargetOids); }
protected void assertAuthorizations(MidPointPrincipal principal, String... expectedAuthorizations) { List<String> actualAuthorizations = new ArrayList<>(); for (Authorization authorization: principal.getAuthorities()) { actualAuthorizations.addAll(authorization.getAction()); } PrismAsserts.assertSets("Wrong authorizations in "+principal, actualAuthorizations, expectedAuthorizations); }
public static <O extends ObjectType> void assertSearchResultNames(SearchResultList<PrismObject<O>> resultList, MatchingRule<String> matchingRule, String... expectedNames) throws SchemaException { List<String> names = new ArrayList<>(expectedNames.length); for(PrismObject<O> obj: resultList) { names.add(obj.asObjectable().getName().getOrig()); } PrismAsserts.assertSets("Unexpected search result", matchingRule, names, expectedNames); }
public static <O extends ObjectType> void assertSearchResultNames(SearchResultList<PrismObject<O>> resultList, String... expectedNames) { List<String> names = new ArrayList<>(expectedNames.length); for(PrismObject<O> obj: resultList) { names.add(obj.asObjectable().getName().getOrig()); } PrismAsserts.assertSets("Unexpected search result", names, expectedNames); }
protected <F extends FocusType> void assertDelegatedRef(PrismObject<F> focus, String... oids) { List<String> refOids = new ArrayList<>(); for (ObjectReferenceType ref: focus.asObjectable().getDelegatedRef()) { refOids.add(ref.getOid()); assertNotNull("Missing type in delegatedRef "+ref.getOid()+" in "+focus, ref.getType()); } PrismAsserts.assertSets("Wrong values in delegatedRef in "+focus, refOids, oids); }
protected <F extends FocusType> void assertRoleMembershipRef(PrismObject<F> focus, String... roleOids) { List<String> refOids = new ArrayList<>(); for (ObjectReferenceType ref: focus.asObjectable().getRoleMembershipRef()) { refOids.add(ref.getOid()); assertNotNull("Missing type in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getType()); // Name is not stored now // assertNotNull("Missing name in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getTargetName()); } PrismAsserts.assertSets("Wrong values in roleMembershipRef in "+focus, refOids, roleOids); }
protected <F extends FocusType> void assertRoleMembershipRefs(PrismObject<F> focus, Collection<String> roleOids) { List<String> refOids = new ArrayList<>(); for (ObjectReferenceType ref: focus.asObjectable().getRoleMembershipRef()) { refOids.add(ref.getOid()); assertNotNull("Missing type in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getType()); // Name is not stored now // assertNotNull("Missing name in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getTargetName()); } PrismAsserts.assertSets("Wrong values in roleMembershipRef in "+focus, refOids, roleOids); }
protected void assertObjectRefs(String contextDesc, boolean checkNames, Collection<ObjectReferenceType> real, String... expected) { List<String> refOids = new ArrayList<>(); for (ObjectReferenceType ref: real) { refOids.add(ref.getOid()); assertNotNull("Missing type in "+ref.getOid()+" in "+contextDesc, ref.getType()); if (checkNames) { assertNotNull("Missing name in " + ref.getOid() + " in " + contextDesc, ref.getTargetName()); } } PrismAsserts.assertSets("Wrong values in "+contextDesc, refOids, expected); }
protected void assertPrismRefValues(String contextDesc, Collection<PrismReferenceValue> real, String... expected) { List<String> refOids = new ArrayList<>(); for (PrismReferenceValue ref: real) { refOids.add(ref.getOid()); assertNotNull("Missing type in "+ref.getOid()+" in "+contextDesc, ref.getTargetType()); assertNotNull("Missing name in "+ref.getOid()+" in "+contextDesc, ref.getTargetName()); } PrismAsserts.assertSets("Wrong values in "+contextDesc, refOids, expected); }
private void assertPolicySituation(PrismObject<UserType> user, String targetOid, String... expectedPolicySituation) { for (AssignmentType assignment: user.asObjectable().getAssignment()) { ObjectReferenceType targetRef = assignment.getTargetRef(); if (targetRef != null && targetOid.equals(targetRef.getOid())) { PrismAsserts.assertSets("Wrong policy situation for target "+targetOid+" in "+user, assignment.getPolicySituation(), expectedPolicySituation); } } }
@Test public void test080TestAttributesToReturn() throws Exception { final String TEST_NAME = "test080TestAttributesToReturn"; displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = task.getResult(); ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ShadowKindType.ENTITLEMENT, RESOURCE_DUMMY_INTENT_GROUP); ProvisioningContext ctx = provisioningContextFactory.create(coords, task, result); // WHEN AttributesToReturn attributesToReturn = ProvisioningUtil.createAttributesToReturn(ctx); // THEN display("attributesToReturn", attributesToReturn); assertFalse("wrong isReturnDefaultAttributes", attributesToReturn.isReturnDefaultAttributes()); Collection<String> attrs = new ArrayList<>(); for (ResourceAttributeDefinition attributeToReturnDef: attributesToReturn.getAttributesToReturn()) { attrs.add(attributeToReturnDef.getName().getLocalPart()); } // No "memebers" attribute here PrismAsserts.assertSets("Wrong attribute to return", attrs, "uid", "name", "description", "cc"); assertSteadyResource(); }
assertNotNull("Account will is gone!", dummyAccount); Set<String> accountProvileges = dummyAccount.getAttributeValues(DummyAccount.ATTR_PRIVILEGES_NAME, String.class); PrismAsserts.assertSets("account privileges", accountProvileges, PRIVILEGE_PILLAGE_NAME, PRIVILEGE_BARGAIN_NAME);