java.util.Set Java Examples

The following examples show how to use java.util.Set. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchemaInterceptor.java    From MyVirtualDirectory with Apache License 2.0 7 votes vote down vote up
/**
 * Checks to see if an attribute is required by as determined from an entry's
 * set of objectClass attribute values.
 *
 * @return true if the objectClass values require the attribute, false otherwise
 * @throws Exception if the attribute is not recognized
 */
private void assertAllAttributesAllowed( Dn dn, Entry entry, Set<String> allowed ) throws LdapException
{
    // Never check the attributes if the extensibleObject objectClass is
    // declared for this entry
    Attribute objectClass = entry.get( OBJECT_CLASS_AT );

    if ( objectClass.contains( SchemaConstants.EXTENSIBLE_OBJECT_OC ) )
    {
        return;
    }

    for ( Attribute attribute : entry )
    {
        String attrOid = attribute.getAttributeType().getOid();

        AttributeType attributeType = attribute.getAttributeType();

        if ( !attributeType.isCollective() && ( attributeType.getUsage() == UsageEnum.USER_APPLICATIONS )
            && !allowed.contains( attrOid ) )
        {
            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, I18n.err( I18n.ERR_277,
                attribute.getUpId(), dn.getName() ) );
        }
    }
}
 
Example #2
Source File: WebContextProducer.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
public CDIPortletWebContext(BeanManager beanManager, VariableValidator variableInspector, Models models,
	String lifecyclePhase, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
	ServletContext servletContext, Locale locale) {

	super(httpServletRequest, httpServletResponse, servletContext, locale);
	this.beanManager = beanManager;
	this.models = models;
	this.beanNames = new HashSet<>();

	boolean headerPhase = lifecyclePhase.equals(PortletRequest.HEADER_PHASE);
	boolean renderPhase = lifecyclePhase.equals(PortletRequest.RENDER_PHASE);
	boolean resourcePhase = lifecyclePhase.equals(PortletRequest.RESOURCE_PHASE);

	Set<Bean<?>> beans = beanManager.getBeans(Object.class, new AnnotationLiteral<Any>() {
			});

	for (Bean<?> bean : beans) {
		String beanName = bean.getName();

		if ((beanName != null) &&
				variableInspector.isValidName(beanName, headerPhase, renderPhase, resourcePhase)) {
			this.beanNames.add(beanName);
		}
	}
}
 
Example #3
Source File: Bind.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
SctpChannel connectChannel(SctpChannel channel)
    throws IOException {
    debug("connecting channel...");
    try {
        SctpServerChannel ssc = SctpServerChannel.open();
        ssc.bind(null);
        Set<SocketAddress> addrs = ssc.getAllLocalAddresses();
        Iterator<SocketAddress> iterator = addrs.iterator();
        SocketAddress addr = iterator.next();
        debug("using " + addr + "...");
        channel.connect(addr);
        SctpChannel peerChannel = ssc.accept();
        ssc.close();
        debug("connected");
        return peerChannel;
    } catch (IOException ioe) {
        debug("Cannot connect channel");
        unexpected(ioe);
        throw ioe;
    }
}
 
Example #4
Source File: Config.java    From ndbc with Apache License 2.0 6 votes vote down vote up
private Config(final String dataSourceSupplierClass, final String host, final int port, final String user,
    final Charset charset, final ScheduledExecutorService scheduler, final Optional<String> password,
    final Optional<String> database, final Optional<Integer> poolMaxSize, final Optional<Integer> poolMaxWaiters,
    final Optional<Duration> connectionTimeout, final Optional<Duration> queryTimeout,
    final Optional<Duration> poolValidationInterval, final Optional<Set<String>> encodingClasses,
    final Optional<Integer> nioThreads, final Optional<SSL> ssl, final Optional<Embedded> embeddedDatabase) {
  this.dataSourceSupplierClass = dataSourceSupplierClass;
  this.charset = charset;
  this.scheduler = scheduler;
  this.user = user;
  this.password = password;
  this.database = database;
  this.host = host;
  this.port = port;
  this.poolMaxSize = poolMaxSize;
  this.poolMaxWaiters = poolMaxWaiters;
  this.connectionTimeout = connectionTimeout;
  this.queryTimeout = queryTimeout;
  this.poolValidationInterval = poolValidationInterval;
  this.encodingClasses = encodingClasses.map(Collections::unmodifiableSet);
  this.nioThreads = nioThreads;
  this.ssl = ssl;
  this.embedded = embeddedDatabase;
}
 
Example #5
Source File: TestImportHandlerStandardPackages.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Test
public void testClassListsAreComplete() throws Exception {
    // Use reflection to get hold of the internal Map
    Class<?> clazz = ImportHandler.class;
    Field f = clazz.getDeclaredField("standardPackages");
    f.setAccessible(true);
    Object obj = f.get(null);

    Assert.assertTrue("Not Map", obj instanceof Map);

    @SuppressWarnings("unchecked")
    Map<String,Set<String>> standardPackageName = (Map<String, Set<String>>) obj;

    for (Map.Entry<String,Set<String>> entry : standardPackageName.entrySet()) {
        checkPackageClassList(entry.getKey(), entry.getValue());
    }
}
 
Example #6
Source File: JpaStorage.java    From apiman with Apache License 2.0 6 votes vote down vote up
/**
 * @see io.apiman.manager.api.core.IStorageQuery#getUserMemberships(java.lang.String, java.lang.String)
 */
@Override
public Set<RoleMembershipBean> getUserMemberships(String userId, String organizationId) throws StorageException {
    Set<RoleMembershipBean> memberships = new HashSet<>();
    beginTx();
    try {
        EntityManager entityManager = getActiveEntityManager();
        CriteriaBuilder builder = entityManager.getCriteriaBuilder();
        CriteriaQuery<RoleMembershipBean> criteriaQuery = builder.createQuery(RoleMembershipBean.class);
        Root<RoleMembershipBean> from = criteriaQuery.from(RoleMembershipBean.class);
        criteriaQuery.where(
                builder.equal(from.get("userId"), userId),
                builder.equal(from.get("organizationId"), organizationId) );
        TypedQuery<RoleMembershipBean> typedQuery = entityManager.createQuery(criteriaQuery);
        List<RoleMembershipBean> resultList = typedQuery.getResultList();
        memberships.addAll(resultList);
        return memberships;
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        throw new StorageException(t);
    } finally {
        rollbackTx();
    }
}
 
Example #7
Source File: WebKitBreakpointManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void add() {
    Set<String> events = eb.getEvents();
    bps = new HashMap<String, org.netbeans.modules.web.webkit.debugging.api.debugger.Breakpoint>(events.size());
    for (String event : events) {
        org.netbeans.modules.web.webkit.debugging.api.debugger.Breakpoint b;
        if (eb.isInstrumentationEvent(event)) {
            b = d.addInstrumentationBreakpoint(event);
        } else {
            b = d.addEventBreakpoint(event);
        }
        if (b != null) {
            bps.put(event, b);
        }
    }
    
}
 
Example #8
Source File: JcloudsLocationSecurityGroupCustomizer.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
private Set<String> getJcloudsLocationIds(final Collection<? extends String> jcloudsApiIds) {
    Set<String> openstackNovaProviders = FluentIterable.from(Providers.all())
            .filter(new Predicate<ProviderMetadata>() {
        @Override
        public boolean apply(ProviderMetadata providerMetadata) {
            return jcloudsApiIds.contains(providerMetadata.getApiMetadata().getId());
        }
    }).transform(new Function<ProviderMetadata, String>() {
        @Nullable
        @Override
        public String apply(ProviderMetadata input) {
            return input.getId();
        }
    }).toSet();

    return new ImmutableSet.Builder<String>()
            .addAll(openstackNovaProviders)
            .addAll(jcloudsApiIds)
            .build();
}
 
Example #9
Source File: Project.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the transitive closure of the library projects for this project
 *
 * @return the transitive closure of the library projects for this project
 */
@NonNull
public List<Project> getAllLibraries() {
    if (mAllLibraries == null) {
        if (mDirectLibraries.isEmpty()) {
            return mDirectLibraries;
        }

        List<Project> all = new ArrayList<Project>();
        Set<Project> seen = Sets.newHashSet();
        Set<Project> path = Sets.newHashSet();
        seen.add(this);
        path.add(this);
        addLibraryProjects(all, seen, path);
        mAllLibraries = all;
    }

    return mAllLibraries;
}
 
Example #10
Source File: ApplicationServletRegistration.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public Set<String> setServletSecurity(ServletSecurityElement constraint) {
    if (constraint == null) {
        throw new IllegalArgumentException(sm.getString(
                "applicationServletRegistration.setServletSecurity.iae",
                getName(), context.getName()));
    }

    if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
        throw new IllegalStateException(sm.getString(
                "applicationServletRegistration.setServletSecurity.ise",
                getName(), context.getName()));
    }

    this.constraint = constraint;
    return context.addServletSecurity(this, constraint);
}
 
Example #11
Source File: SetValueFieldDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void setComboBoxes() {
  // Something was changed in the row.
  //
  final Map<String, Integer> fields = new HashMap<String, Integer>();

  // Add the currentMeta fields...
  fields.putAll( inputFields );

  Set<String> keySet = fields.keySet();
  List<String> entries = new ArrayList<String>( keySet );

  String[] fieldNames = entries.toArray( new String[entries.size()] );

  Const.sortStrings( fieldNames );
  colinf[0].setComboValues( fieldNames );
  colinf[1].setComboValues( fieldNames );
}
 
Example #12
Source File: CallbacksSecurityTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private static String getCurrentSubjectName() {
	final AccessControlContext acc = AccessController.getContext();

	return AccessController.doPrivileged(new PrivilegedAction<String>() {

		@Override
		public String run() {
			Subject subject = Subject.getSubject(acc);
			if (subject == null) {
				return null;
			}

			Set<Principal> principals = subject.getPrincipals();

			if (principals == null) {
				return null;
			}
			for (Principal p : principals) {
				return p.getName();
			}
			return null;
		}
	});
}
 
Example #13
Source File: PluginLoader.java    From nano-framework with Apache License 2.0 6 votes vote down vote up
private void initModules() throws Throwable {
    final Set<String> moduleNames = SPILoader.spiNames(Module.class);
    if (!CollectionUtils.isEmpty(moduleNames)) {
        final Injector injector = Globals.get(Injector.class);
        final Map<Integer, List<Module>> modules = Maps.newHashMap();
        for (final String moduleName : moduleNames) {
            final Module module = injector.getInstance(Key.get(Module.class, Names.named(moduleName)));
            final Level level = module.getClass().getAnnotation(Level.class);
            if (level != null) {
                addModules(modules, level.value(), module);
            } else {
                addModules(modules, 0, module);
            }
        }

        loadModules(modules);
    }
}
 
Example #14
Source File: AbstractQualifiedListFacetTest.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testTypeAddAllNullInList()
{
	T t1 = getObject();
	T t2 = getObject();
	List<T> pct = new ArrayList<>();
	pct.add(t1);
	pct.add(null);
	pct.add(t2);
	Object source1 = new Object();
	assertThrows(NullPointerException.class,
			() -> getFacet().addAll(id, pct, source1)
	);
	/*
	 * TODO This should be zero, one or two???
	 */
	assertEquals(1, getFacet().getCount(id));
	assertFalse(getFacet().isEmpty(id));
	Set<T> setoftwo = getFacet().getSet(id);
	assertNotNull(setoftwo);
	assertEquals(1, setoftwo.size());
	assertTrue(setoftwo.contains(t1));
	assertEventCount(1, 0);
}
 
Example #15
Source File: DatePartDiscontinousRangeEnumeratorUnitTest.java    From tddl with Apache License 2.0 6 votes vote down vote up
@Test
// @T gmt> 10,2,5 +一段时间 gmt< 10,2,6号中一个时间的
public void test39() throws Exception {

    btc = gand(gcomp(getDate(110, 02, 5, 0, 0, 1), GreaterThan),
        gcomp(getDate(110, 02, 6, 23, 59, 59), TestUtils.LessThanOrEqual));
    Set<Object> s = e.getEnumeratedValue(btc, 7, 1, needMergeValueInCloseRange);
    TestUtils.testSetDate(new Date[] { getDate(110, 02, 5, 0, 0, 1), getDate(110, 02, 6, 0, 0, 1),
            getDate(110, 02, 6, 23, 59, 59) },
        s);

    s = e.getEnumeratedValue(btc, 7, 1, needMergeValueInCloseRange);
    TestUtils.testSetDate(new Date[] { getDate(110, 02, 5, 0, 0, 1), getDate(110, 02, 6, 0, 0, 1),
            getDate(110, 02, 6, 23, 59, 59) },
        s);
}
 
Example #16
Source File: ConversationTestBase.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Checks that the set of all reply threads of a blip is the same as the union
 * of the inline reply and non-inline reply threads.
 */
private static void assertThreadChildrenConsistent(ConversationBlip blip) {
  Set<ConversationThread> allChildren =
      new HashSet<ConversationThread>();
  for (ConversationThread thread : blip.getReplyThreads()) {
    assertFalse(allChildren.contains(thread));
    allChildren.add(thread);
  }
  for (ConversationThread child : blip.getReplyThreads()) {
    assertTrue(allChildren.contains(child));
    allChildren.remove(child);
  }
  // make sure they are exactly equals
  assertEquals(0, allChildren.size());
}
 
Example #17
Source File: AnnotatedValueResolver.java    From armeria with Apache License 2.0 5 votes vote down vote up
private static void warnOnDuplicateResolver(Executable constructorOrMethod,
                                            List<AnnotatedValueResolver> list) {
    final Set<AnnotatedValueResolver> uniques = AnnotatedBeanFactoryRegistry.uniqueResolverSet();
    list.forEach(element -> {
        if (!uniques.add(element)) {
            AnnotatedBeanFactoryRegistry.warnDuplicateResolver(
                    element, constructorOrMethod.toGenericString());
        }
    });
}
 
Example #18
Source File: VectorX.java    From pra with MIT License 5 votes vote down vote up
public VectorI idxOut(Set<T> m) {
	VectorI v = new VectorI();
	for (int i = 0; i < size(); ++i) {
		if (!m.contains(this.get(i))) v.add(i);
	}
	return v;
}
 
Example #19
Source File: ClusterCommunicationManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public <M> void multicast(M message,
                          MessageSubject subject,
                          Function<M, byte[]> encoder,
                          Set<NodeId> nodes) {
    checkPermission(CLUSTER_WRITE);
    byte[] payload = new ClusterMessage(
            localNodeId,
            subject,
            timeFunction(encoder, subjectMeteringAgent, SERIALIZING).apply(message))
            .getBytes();
    nodes.forEach(nodeId -> doUnicast(subject, payload, nodeId));
}
 
Example #20
Source File: AqlViewer.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
private <Ty, En, Sym, Fk, Att, Gen, Sk, X, Y> Map<Ty, Object[][]> makeTyTables(Map<Ty, Set<Y>> m,
		Algebra<Ty, En, Sym, Fk, Att, Gen, Sk, X, Y> alg) {
	Map<Ty, Object[][]> ret = new LinkedHashMap<>();

	List<Ty> tys = Util.alphabetical(alg.schema().typeSide.tys);

	for (Ty ty : tys) {
		if (!m.containsKey(ty)) {
			continue;
		}
		int n = Integer.min(maxrows, m.get(ty).size());

		Object[][] data = new Object[n][1];
		int i = 0;
		for (Y y : Util.alphabetical(m.get(ty))) {
			Object[] row = new Object[1];
			row[0] = alg.printY(ty, y);
			data[i] = row;
			i++;
			if (i == n) {
				break;
			}
		}
		ret.put(ty, data);
	}
	return ret;
}
 
Example #21
Source File: RecommendationContext.java    From seldon-server with Apache License 2.0 5 votes vote down vote up
public RecommendationContext(MODE mode, Set<Long> contextItems, Set<Long> exclusionItems, List<String> inclusionKeys, Long currentItem,
                             String lastRecListUUID, OptionsHolder optsHolder) {
	if (logger.isDebugEnabled())
		logger.debug("Built new rec context object in mode " +mode.name());

    this.mode = mode;
    this.contextItems = contextItems;
    this.exclusionItems = exclusionItems;
    this.currentItem = currentItem;
    this.inclusionKeys = inclusionKeys;
    this.lastRecListUUID = lastRecListUUID;
    this.optsHolder = optsHolder;
}
 
Example #22
Source File: LibraryDataService.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public Map<OrderRootType, Collection<File>> prepareLibraryFiles(@Nonnull LibraryData data) {
  Map<OrderRootType, Collection<File>> result = ContainerUtilRt.newHashMap();
  for (LibraryPathType pathType : LibraryPathType.values()) {
    final Set<String> paths = data.getPaths(pathType);
    if (paths.isEmpty()) {
      continue;
    }
    result.put(myLibraryPathTypeMapper.map(pathType), ContainerUtil.map(paths, File::new));
  }
  return result;
}
 
Example #23
Source File: TCKDateTimeFormatter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_resolverFields_Set_null() throws Exception {
    DateTimeFormatter f = DateTimeFormatter.ISO_DATE.withResolverFields(MONTH_OF_YEAR);
    assertEquals(f.getResolverFields().size(), 1);
    f = f.withResolverFields((Set<TemporalField>) null);
    assertEquals(f.getResolverFields(), null);
}
 
Example #24
Source File: UpdateExprBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Set<Var> getProjectionVars(Collection<StatementPattern> statementPatterns) {
	Set<Var> vars = new LinkedHashSet<>(statementPatterns.size() * 2);

	for (StatementPattern sp : statementPatterns) {
		vars.add(sp.getSubjectVar());
		vars.add(sp.getPredicateVar());
		vars.add(sp.getObjectVar());
		if (sp.getContextVar() != null) {
			vars.add(sp.getContextVar());
		}
	}

	return vars;
}
 
Example #25
Source File: ElementFilter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static ElementFilter forTypesFromNamespaces(final Set<QualifiedName> namespaces) {
    Set<ElementFilter> filters = new HashSet<>();
    for (QualifiedName ns : namespaces) {
        filters.add(ElementFilter.forTypesFromNamespace(ns));
    }
    return ElementFilter.anyOf(filters);

}
 
Example #26
Source File: ExternalLibraryBuilder.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Deletes all entries in the Xtext index that originate from one of the given {@code projectsToBeWiped}.
 *
 * @param projectsToBeWiped
 *            The projects to be wiped.
 */
public void wipeProjectFromIndex(IProgressMonitor monitor, Collection<N4JSExternalProject> projectsToBeWiped) {
	final Set<FileURI> toBeWiped = new HashSet<>();
	for (N4JSExternalProject project : projectsToBeWiped) {
		toBeWiped.add(project.getSafeLocation());
	}
	this.wipeURIsFromIndex(monitor, toBeWiped);
}
 
Example #27
Source File: HeadlessCrawlerTableTransformerTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
private Set<String> runUrlFetching(String mainAppPage, TableProperties tableProperties,
                                   List<String> expectedSeedRelativeUrls, CrawlController crawlController,
                                   InOrder ordered)
{
    URI mainAppPageUri = URI.create(mainAppPage);
    doNothing().when(crawlController).start((WebCrawlerFactory<?>) argThat(factory ->
    {
        if (factory instanceof LinkCrawlerFactory)
        {
            LinkCrawler linkCrawler = ((LinkCrawlerFactory) factory).newInstance();
            HtmlParseData htmlParseData = new HtmlParseData();
            String outgoingUrl = UriUtils.buildNewUrl(mainAppPage, OUTGOING_ABSOLUT_URL).toString();
            htmlParseData.setOutgoingUrls(Set.of(createWebUrl(outgoingUrl)));
            String crawlingPageUrl = UriUtils.buildNewUrl(mainAppPage, CRAWLING_RELATIVE_URL).toString();
            WebURL crawlingPageWebUrl = createWebUrl(crawlingPageUrl);
            Page page = new Page(crawlingPageWebUrl);
            page.setParseData(htmlParseData);
            if (linkCrawler.shouldVisit(page, crawlingPageWebUrl))
            {
                linkCrawler.visit(page);
            }
            return true;
        }
        return false;
    }), eq(50));
    Set<String> urls = transformer.fetchUrls(tableProperties);
    ordered.verify(crawlControllerFactory).createCrawlController(mainAppPageUri);
    Stream.concat(Stream.of(mainAppPage),
            expectedSeedRelativeUrls.stream().map(HeadlessCrawlerTableTransformerTests::buildAppPageUrl))
            .forEach(url -> ordered.verify(crawlController).addSeed(url));
    ordered.verify(crawlController).start(any(LinkCrawlerFactory.class), eq(50));
    verifyNoMoreInteractions(crawlController);
    return urls;
}
 
Example #28
Source File: Schemas.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void clusterChanged(ClusterChangedEvent event) {
    if (!event.metaDataChanged()) {
        return;
    }

    Set<String> newCurrentSchemas = getNewCurrentSchemas(event.state().metaData());
    synchronized (schemas) {
        Sets.SetView<String> nonBuiltInSchemas = Sets.difference(schemas.keySet(), builtInSchemas.keySet());
        Set<String> deleted = Sets.difference(nonBuiltInSchemas, newCurrentSchemas).immutableCopy();
        Set<String> added = Sets.difference(newCurrentSchemas, schemas.keySet()).immutableCopy();

        for (String deletedSchema : deleted) {
            try {
                schemas.remove(deletedSchema).close();
            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
            }
        }

        for (String addedSchema : added) {
            schemas.put(addedSchema, getCustomSchemaInfo(addedSchema));
        }

        // update all existing schemas
        for (SchemaInfo schemaInfo : this) {
            schemaInfo.update(event);
        }
    }
}
 
Example #29
Source File: CreateSymbols.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Map<String, String> buildPackage2Modules(Path jdkRoot) throws IOException {
    if (jdkRoot == null) //in tests
        return Collections.emptyMap();

    Map<String, String> result = new HashMap<>();
    try (DirectoryStream<Path> repositories = Files.newDirectoryStream(jdkRoot)) {
        for (Path repository : repositories) {
            Path src = repository.resolve("src");
            if (!Files.isDirectory(src))
                continue;
            try (DirectoryStream<Path> modules = Files.newDirectoryStream(src)) {
                for (Path module : modules) {
                    Path shareClasses = module.resolve("share/classes");

                    if (!Files.isDirectory(shareClasses))
                        continue;

                    Set<String> packages = new HashSet<>();

                    packages(shareClasses, new StringBuilder(), packages);

                    for (String p : packages) {
                        if (result.containsKey(p))
                            throw new IllegalStateException("Duplicate package mapping.");
                        result.put(p, module.getFileName().toString());
                    }
                }
            }
        }
    }

    return result;
}
 
Example #30
Source File: MapValuesToFutureOfCompletedValuesTest.java    From commercetools-sync-java with Apache License 2.0 5 votes vote down vote up
@Test
void multiple_SetToListWithDiffTypeMappingDuplicates_ReturnsFutureOfListOfMappedValuesWithDuplicates() {
    final Set<String> set = new HashSet<>();
    set.add("foo");
    set.add("bar");

    final CompletableFuture<List<Integer>> future = mapValuesToFutureOfCompletedValues(set,
        element -> completedFuture(element.length()), toList());
    final List<Integer> result = future.join();
    assertThat(result).containsExactly(3, 3);
    assertThat(result).isExactlyInstanceOf(ArrayList.class);
}