@Test public void testContainAllMandotory() { String testTitle = "Contain all mandatory actions"; LOG.info("[Test] "+testTitle); List<Action> requestedActions = null; List<Action> providedActions = null; assertTrue("Null requested actions means nothing is mandatory", ActionUtils.containAllMandotory(providedActions, requestedActions)); requestedActions = new ArrayList<Action>(); assertTrue("Empty requested actions means nothing is mandatory (1/2)", ActionUtils.containAllMandotory(providedActions, requestedActions)); providedActions = new ArrayList<Action>(); assertTrue("Empty requested actions means nothing is mandatory (2/2)", ActionUtils.containAllMandotory(providedActions, requestedActions)); requestedActions = ActionUtils.createList(ActionConstants.READ); assertFalse("Only Mandatory requested actions (1/2)", ActionUtils.containAllMandotory(providedActions, requestedActions)); providedActions = ActionUtils.createList(ActionConstants.READ); assertTrue("Empty requested actions means nothing is mandatory (2/4)", ActionUtils.containAllMandotory(providedActions, requestedActions)); requestedActions = ActionUtils.createList(ActionConstants.READ, ActionConstants.WRITE); assertFalse("Only Mandatory requested actions (3/4)", ActionUtils.containAllMandotory(providedActions, requestedActions)); providedActions = ActionUtils.createList(ActionConstants.READ, ActionConstants.WRITE); assertTrue("Empty requested actions means nothing is mandatory (4/4)", ActionUtils.containAllMandotory(providedActions, requestedActions)); requestedActions.add(ActionUtils.create(ActionConstants.DELETE, true)); assertTrue("With option field, it should still match (1/3)", ActionUtils.containAllMandotory(providedActions, requestedActions)); providedActions.add(ActionUtils.create(ActionConstants.DELETE, true)); assertTrue("With option field, it should still match (2/3)", ActionUtils.containAllMandotory(providedActions, requestedActions)); providedActions = ActionUtils.createList(ActionConstants.READ, ActionConstants.WRITE, ActionConstants.DELETE); assertTrue("Empty requested actions means nothing is mandatory (3/3)", ActionUtils.containAllMandotory(providedActions, requestedActions)); requestedActions = new ArrayList<Action>(); requestedActions.add(ActionUtils.create(ActionConstants.DELETE, true)); providedActions = null; assertTrue("Only optional field, it should still match (1/4)", ActionUtils.containAllMandotory(providedActions, requestedActions)); providedActions = new ArrayList<Action>(); assertTrue("Only optional field, it should still match (2/4)", ActionUtils.containAllMandotory(providedActions, requestedActions)); providedActions.add(ActionUtils.create(ActionConstants.DELETE, true)); assertTrue("Only optional field, it should still match (3/4)", ActionUtils.containAllMandotory(providedActions, requestedActions)); providedActions = ActionUtils.createList(ActionConstants.READ, ActionConstants.WRITE, ActionConstants.DELETE); assertTrue("Only optional field, it should still match (4/4)", ActionUtils.containAllMandotory(providedActions, requestedActions)); }
public static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack) { if (null == haystack || haystack.size() <= 0) { return true; } for (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action entry : haystack){ if (entry.isOptional()) { continue; } if (!contain(entry, needles)) { return false; } } return true; }
ActionUtils { public static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack) { if (null == haystack || haystack.size() <= 0) { return true; } for (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action entry : haystack){ if (entry.isOptional()) { continue; } if (!contain(entry, needles)) { return false; } } return true; } }
ActionUtils { public static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack) { if (null == haystack || haystack.size() <= 0) { return true; } for (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action entry : haystack){ if (entry.isOptional()) { continue; } if (!contain(entry, needles)) { return false; } } return true; }  }
ActionUtils { public static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack) { if (null == haystack || haystack.size() <= 0) { return true; } for (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action entry : haystack){ if (entry.isOptional()) { continue; } if (!contain(entry, needles)) { return false; } } return true; }  static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action create(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ActionConstants actionConstant); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action create(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ActionConstants actionConstant, boolean optional); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action create(String actionConstantValue, boolean optional); static List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> createList(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ActionConstants... actionConstants); static String getFriendlyName(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action entry); static List<String> getFriendlyName(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack); static String getFriendlyDescription(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack); static String getFriendlyDescription(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack, boolean displayOptionalString); static String toXmlString(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action action); static String toXmlString(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actions); static String toString(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action action); static String toString(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actions); static boolean atLeast1MandatoryAction(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actions); static boolean equal(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action o1, Object o2, boolean dontCheckOptional); @Deprecated static boolean equals(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action o1, Object o2); static boolean equal(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action o1, Object o2); static boolean equal(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> o1, Object o2); @Deprecated static boolean equals(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> o1, Object o2); static boolean contain(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action needle, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack); static boolean contains(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action needle, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack); static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack); static boolean contains(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actionsToCheck, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actions); static boolean contains(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actionsToCheck, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actions, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> intersection); static boolean containsOr(List<Action> actionsToCheck, List<Action> actions); static List<Action> intersect(List<Action> actionsToCheck, List<Action> actions); static Action toAction(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action actionBean); static List<Action> toActions(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actionBeans); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action toActionBean(Action action); static List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> toActionBeans(List<Action> actions); }
ActionUtils { public static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack) { if (null == haystack || haystack.size() <= 0) { return true; } for (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action entry : haystack){ if (entry.isOptional()) { continue; } if (!contain(entry, needles)) { return false; } } return true; }  static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action create(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ActionConstants actionConstant); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action create(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ActionConstants actionConstant, boolean optional); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action create(String actionConstantValue, boolean optional); static List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> createList(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ActionConstants... actionConstants); static String getFriendlyName(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action entry); static List<String> getFriendlyName(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack); static String getFriendlyDescription(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack); static String getFriendlyDescription(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack, boolean displayOptionalString); static String toXmlString(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action action); static String toXmlString(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actions); static String toString(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action action); static String toString(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actions); static boolean atLeast1MandatoryAction(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actions); static boolean equal(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action o1, Object o2, boolean dontCheckOptional); @Deprecated static boolean equals(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action o1, Object o2); static boolean equal(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action o1, Object o2); static boolean equal(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> o1, Object o2); @Deprecated static boolean equals(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> o1, Object o2); static boolean contain(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action needle, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack); static boolean contains(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action needle, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack); static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> haystack); static boolean contains(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actionsToCheck, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actions); static boolean contains(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actionsToCheck, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actions, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> intersection); static boolean containsOr(List<Action> actionsToCheck, List<Action> actions); static List<Action> intersect(List<Action> actionsToCheck, List<Action> actions); static Action toAction(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action actionBean); static List<Action> toActions(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> actionBeans); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action toActionBean(Action action); static List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Action> toActionBeans(List<Action> actions); static Map<String, String> map2FriendlyName; }