@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof SimpleClassNode)) return false; SimpleClassNode other = (SimpleClassNode) obj; if (uris == null) { if (other.uris != null) return false; } else if (!SetUtils.isEqualSet(uris, other.uris)) return false; return true; }
/** * Copies the fields. * @param src * @param dest * @return true if any modification is detected, otherwise false. */ public static boolean copyGroupFields(final LdapGroup src, final LdapGroup dest) { boolean modified; final List<String> properties = new LinkedList<String>(); ListHelper.addAll(properties, "description", "organization"); if (LdapUserDao.isPosixAccountsConfigured() == true && isPosixAccountValuesEmpty(src) == false) { ListHelper.addAll(properties, "gidNumber"); } modified = BeanHelper.copyProperties(src, dest, true, properties.toArray(new String[0])); // Checks if the sets aren't equal: if (SetUtils.isEqualSet(src.getMembers(), dest.getMembers()) == false) { if (LdapGroupDao.hasMembers(src) == true || LdapGroupDao.hasMembers(dest) == true) { // If both, src and dest have no members, then do nothing, otherwise: modified = true; dest.clearMembers(); dest.addAllMembers(src.getMembers()); } } return modified; }
@Test public void getAllBranches() throws IOException, SchemaBranchNotFoundException, InvalidSchemaException, SchemaNotFoundException, IncompatibleSchemaException, SchemaBranchAlreadyExistsException { SchemaMetadata schemaMetadata = addSchemaMetadata(testNameRule.getMethodName(), SchemaCompatibility.NONE); SchemaIdVersion masterSchemaIdVersion1 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device.avsc"); SchemaBranch schemaBranch1 = addSchemaBranch("BRANCH1", schemaMetadata, masterSchemaIdVersion1.getSchemaVersionId()); SchemaIdVersion masterSchemaIdVersion2 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device-incompat.avsc"); SchemaBranch schemaBranch2 = addSchemaBranch("BRANCH2", schemaMetadata, masterSchemaIdVersion2.getSchemaVersionId()); Set<String> actualSchemaBranches = schemaRegistryClient.getSchemaBranches(schemaMetadata.getName()).stream().map(branch -> branch.getName()).collect(Collectors.toSet()); Set<String> expectedSchemaBranches = new HashSet<>(Lists.newArrayList("MASTER", schemaBranch1.getName(), schemaBranch2.getName())); Assert.assertTrue(SetUtils.isEqualSet(actualSchemaBranches, expectedSchemaBranches)); }
@Test public void create_new_set_apache () { @SuppressWarnings("unchecked") Set<String> newSet = SetUtils.EMPTY_SET; assertNotNull(newSet); }
@Test public void return_empty_set_apache_commons () { @SuppressWarnings("unchecked") Set<String> emptySet = SetUtils.EMPTY_SET; assertTrue(emptySet.isEmpty()); }
/** * Used for post example */ @SuppressWarnings({ "unused", "unchecked" }) private void return_empty_set_apache_commons_exception () { DomainObject domain = null; // dao populate domain Set<String> strings; if (domain != null && !CollectionUtils.isEmpty(domain.getStrings())) { strings = domain.getStrings(); } else { strings = SetUtils.EMPTY_SET; } //... }
@SuppressWarnings("unchecked") // apache commons collection api does not support generics public static Set<Class<? extends Page>> getAnnotatedWicketPage(String packageScanPath, Class<? extends Annotation> annotationClazz) { Reflections reflections = new Reflections(packageScanPath); return SetUtils.predicatedSet(reflections.getTypesAnnotatedWith(annotationClazz), PAGE_PREDICATE); }
@Test public void return_empty_sorted_set_apache_commons () { @SuppressWarnings("unchecked") Set<String> emptySortedSet = SetUtils.EMPTY_SORTED_SET; assertTrue(emptySortedSet.isEmpty()); }