@Test public void testContainAllMandotory() { String testTitle = "Contain all mandatory actions"; LOG.info("[Test] "+testTitle); List<Condition> requestedConditions = null; List<Condition> providedConditions = null; assertTrue("Null requested conditions means nothing is mandatory", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); requestedConditions = new ArrayList<Condition>(); assertTrue("Empty requested conditions means nothing is mandatory (1/2)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); providedConditions = new ArrayList<Condition>(); assertTrue("Empty requested conditions means nothing is mandatory (2/2)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); requestedConditions.add(ConditionUtils.create(ConditionConstants.SHARE_WITH_3RD_PARTIES, "1")); assertFalse("Only Mandatory requested conditions (1/5)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); providedConditions.add(ConditionUtils.create(ConditionConstants.SHARE_WITH_3RD_PARTIES, "1")); assertTrue("Only Mandatory requested conditions (2/5)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); requestedConditions.add(ConditionUtils.create(ConditionConstants.DATA_RETENTION_IN_MINUTES, "25")); assertFalse("Only Mandatory requested conditions (3/5)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); providedConditions.add(ConditionUtils.create(ConditionConstants.DATA_RETENTION_IN_MINUTES, "25")); assertTrue("Only Mandatory requested conditions (4/5)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); providedConditions.add(ConditionUtils.create(ConditionConstants.RIGHT_TO_CORRECT_INCORRECT_DATA, "1")); assertTrue("Only Mandatory requested conditions, even with provided more data (5/5)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); requestedConditions.add(ConditionUtils.create(ConditionConstants.MAY_BE_INFERRED, "0", true)); assertTrue("With option field, it should still match (1/3)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); providedConditions.add(ConditionUtils.create(ConditionConstants.MAY_BE_INFERRED, "0", true)); assertTrue("With option field, it should still match (2/3)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); providedConditions = new ArrayList<Condition>(); providedConditions.add(ConditionUtils.create(ConditionConstants.MAY_BE_INFERRED, "0")); providedConditions.add(ConditionUtils.create(ConditionConstants.SHARE_WITH_3RD_PARTIES, "1")); providedConditions.add(ConditionUtils.create(ConditionConstants.DATA_RETENTION_IN_MINUTES, "25")); assertTrue("With option field, it should still match (3/3)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); requestedConditions = new ArrayList<Condition>(); requestedConditions.add(ConditionUtils.create(ConditionConstants.DATA_RETENTION_IN_HOURS, "10", true)); providedConditions = null; assertTrue("Only optional field, it should still match (1/4)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); providedConditions = new ArrayList<Condition>(); assertTrue("Only optional field, it should still match (2/4)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); providedConditions.add(ConditionUtils.create(ConditionConstants.DATA_RETENTION_IN_HOURS, "10", true)); assertTrue("Only optional field, it should still match (3/4)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); providedConditions = new ArrayList<Condition>(); providedConditions.add(ConditionUtils.create(ConditionConstants.DATA_RETENTION_IN_MINUTES, "25")); providedConditions.add(ConditionUtils.create(ConditionConstants.MAY_BE_INFERRED, "0", true)); assertTrue("Only optional field, it should still match (4/4)", ConditionUtils.containAllMandotory(providedConditions, requestedConditions)); }
public static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> haystack) { if (null == haystack || haystack.size() <= 0) { return true; } for (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition entry : haystack){ if (entry.isOptional()) { continue; } if (!contain(entry, needles)) { return false; } } return true; }
ConditionUtils { public static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> haystack) { if (null == haystack || haystack.size() <= 0) { return true; } for (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition entry : haystack){ if (entry.isOptional()) { continue; } if (!contain(entry, needles)) { return false; } } return true; } }
ConditionUtils { public static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> haystack) { if (null == haystack || haystack.size() <= 0) { return true; } for (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition entry : haystack){ if (entry.isOptional()) { continue; } if (!contain(entry, needles)) { return false; } } return true; }  }
ConditionUtils { public static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> haystack) { if (null == haystack || haystack.size() <= 0) { return true; } for (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition entry : haystack){ if (entry.isOptional()) { continue; } if (!contain(entry, needles)) { return false; } } return true; }  static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition create(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ConditionConstants conditionConstant, String value); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition create(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ConditionConstants conditionConstant, String value, boolean optional); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition createPrivate(); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition createMembersOnly(); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition createPublic(); static String toXmlString(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition condition); static String toXmlString(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> conditions); static String toString(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition condition); static String toString(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> conditions); static String getFriendlyName(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition entry); List<String> getFriendlyName(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> haystack); static boolean equal(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition o1, Object o2, boolean dontCheckOptional); @Deprecated static boolean equals(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition o1, Object o2); static boolean equal(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition o1, Object o2); static boolean equal(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> o1, Object o2); static boolean contain(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition conditionToCheck, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> conditions); static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> haystack); static Condition toCondition(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition conditionBean); static List<Condition> toConditions(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> conditionBeans); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition toConditionBean(Condition condition); static List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> toConditionBeans(List<Condition> conditions); static boolean contains(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ConditionConstants conditionToCheck, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> conditions); static boolean contains(Condition conditionToCheck, List<Condition> conditions); static boolean contains(List<Condition> conditionsToCheck, List<Condition> conditions); static boolean containsOr(List<Condition> conditionsToCheck, List<Condition> conditions); }
ConditionUtils { public static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> haystack) { if (null == haystack || haystack.size() <= 0) { return true; } for (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition entry : haystack){ if (entry.isOptional()) { continue; } if (!contain(entry, needles)) { return false; } } return true; }  static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition create(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ConditionConstants conditionConstant, String value); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition create(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ConditionConstants conditionConstant, String value, boolean optional); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition createPrivate(); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition createMembersOnly(); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition createPublic(); static String toXmlString(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition condition); static String toXmlString(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> conditions); static String toString(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition condition); static String toString(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> conditions); static String getFriendlyName(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition entry); List<String> getFriendlyName(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> haystack); static boolean equal(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition o1, Object o2, boolean dontCheckOptional); @Deprecated static boolean equals(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition o1, Object o2); static boolean equal(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition o1, Object o2); static boolean equal(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> o1, Object o2); static boolean contain(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition conditionToCheck, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> conditions); static boolean containAllMandotory(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> needles, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> haystack); static Condition toCondition(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition conditionBean); static List<Condition> toConditions(List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> conditionBeans); static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition toConditionBean(Condition condition); static List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> toConditionBeans(List<Condition> conditions); static boolean contains(org.societies.api.schema.privacytrust.privacy.model.privacypolicy.ConditionConstants conditionToCheck, List<org.societies.api.schema.privacytrust.privacy.model.privacypolicy.Condition> conditions); static boolean contains(Condition conditionToCheck, List<Condition> conditions); static boolean contains(List<Condition> conditionsToCheck, List<Condition> conditions); static boolean containsOr(List<Condition> conditionsToCheck, List<Condition> conditions); static Map<String, String> map2FriendlyName; }