List of usage examples for java.util Collections emptySet
@SuppressWarnings("unchecked") public static final <T> Set<T> emptySet()
From source file:io.fabric8.elasticsearch.plugin.auth.OpenShiftTokenAuthenticationTest.java
@Test public void testAuthenticate() throws Exception { when(apiService.localSubjectAccessReview(anyString(), anyString(), anyString(), anyString(), anyString(), eq(ArrayUtils.EMPTY_STRING_ARRAY))).thenReturn(true); when(contextFactory.create(any(RestRequest.class))).thenReturn(context); threadContext.putTransient(ConfigurationSettings.OPENSHIFT_REQUEST_CONTEXT, new OpenshiftRequestContext(username, "atoken", false, Collections.emptySet(), null, null)); User expUser = new User(username); expUser.addRole(BaseRolesSyncStrategy.formatUserRoleName(username)); expUser.addRole(BaseRolesSyncStrategy.formatUserKibanaRoleName(username)); expUser.addRole(SearchGuardRolesMapping.ADMIN_ROLE); expUser.addRole("prometheus"); User user = backend.authenticate(new AuthCredentials(username)); assertEquals(expUser, user);//from w w w. jav a 2 s . co m }
From source file:com.phoenixnap.oss.ramlapisync.data.ApiActionMetadata.java
public Set<ApiParameterMetadata> getRequestHeaders() { if (requestHeaders == null) { return Collections.emptySet(); }//from w ww. j a v a 2 s . c o m return requestHeaders; }
From source file:com.ikanow.aleph2.analytics.spark.services.SparkPyWrapperService.java
/** Returns a union of all the types (for convenience) * @return/*from w w w .jav a 2 s . c om*/ */ @SuppressWarnings("unchecked") public JavaRDD<Map<String, Object>> getAllRddInputs() { initializeRdd(Collections.emptySet()); // (not sure why the cast is needed, eclipse happy but maven fails) return (JavaRDD<Map<String, Object>>) _rdd_set.get().values().stream() .reduce((acc1, acc2) -> acc1.union(acc2)) .<JavaRDD<Map<String, Object>>>map(rdd -> rdd .<Map<String, Object>>map(t2 -> _mapper.convertValue(t2._2()._2().getJson(), Map.class))) .orElse(null); }
From source file:com.cognifide.aet.cleaner.processors.GetMetadataArtifactsProcessor.java
private Set<String> traverseComparators(Step step) { Set<String> stepArtifacts = Collections.emptySet(); if (step.getComparators() != null) { stepArtifacts = FluentIterable.from(step.getComparators()).filter(STEP_RESULTS_WITH_ARTIFACT_ID) .transform(COMPARATOR_TO_ARTIFACT_ID).toSet(); }//from w w w . j a va2 s . co m return stepArtifacts; }
From source file:de.cosmocode.palava.ipc.xml.rpc.HttpHandler.java
private Set<Cookie> getCookies(HttpRequest request) { final CookieDecoder decoder = new CookieDecoder(); final String cookieString = request.getHeader(Names.COOKIE); if (StringUtils.isBlank(cookieString)) return Collections.emptySet(); return decoder.decode(cookieString); }
From source file:alfio.manager.user.UserManager.java
public Collection<Role> getAvailableRoles(String username) { User user = findUserByUsername(username); return isAdmin(user) || isOwner(user) ? EnumSet.of(Role.OWNER, Role.OPERATOR, Role.SUPERVISOR, Role.SPONSOR, Role.API_CONSUMER) : Collections.emptySet(); }
From source file:com.devicehive.service.DeviceCommandServiceTest.java
@Test @DirtiesContext(methodMode = DirtiesContext.MethodMode.BEFORE_METHOD) public void testFindCommandsByGuid() throws Exception { final List<String> guids = IntStream.range(0, 5).mapToObj(i -> UUID.randomUUID().toString()) .collect(Collectors.toList()); final Date timestampSt = timestampService.getDate(); final Date timestampEnd = timestampService.getDate(); final String parameters = "{\"param1\":\"value1\",\"param2\":\"value2\"}"; final Set<String> guidsForSearch = new HashSet<>(Arrays.asList(guids.get(0), guids.get(2), guids.get(3))); final Map<String, DeviceCommand> commandMap = guidsForSearch.stream() .collect(Collectors.toMap(Function.identity(), guid -> { DeviceCommand command = new DeviceCommand(); command.setId(System.nanoTime()); command.setDeviceGuid(guid); command.setCommand(RandomStringUtils.randomAlphabetic(10)); command.setTimestamp(timestampService.getDate()); command.setParameters(new JsonStringWrapper(parameters)); command.setStatus(DEFAULT_STATUS); return command; }));/*w w w . ja v a 2 s. c om*/ when(requestHandler.handle(any(Request.class))).then(invocation -> { Request request = invocation.getArgumentAt(0, Request.class); String guid = request.getBody().cast(CommandSearchRequest.class).getGuid(); CommandSearchResponse response = new CommandSearchResponse(); response.setCommands(Collections.singletonList(commandMap.get(guid))); return Response.newBuilder().withBody(response).buildSuccess(); }); deviceCommandService.find(guidsForSearch, Collections.emptySet(), timestampSt, timestampEnd, DEFAULT_STATUS) .thenAccept(commands -> { assertEquals(3, commands.size()); assertEquals(new HashSet<>(commandMap.values()), new HashSet<>(commands)); }).get(15, TimeUnit.SECONDS); verify(requestHandler, times(3)).handle(argument.capture()); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.admin.WaitForBackgroundThreadsController.java
/** * Wait until all background threads have become idle, or until the time * limit is passed. Return the names of any that are still active; hopefully * an empty list.// w ww . ja va 2 s . co m */ private Collection<String> waitForThreads(int maximumWait) { int elapsedSeconds = 0; while (true) { Collection<String> threadNames = getNamesOfBusyThreads(); if (threadNames.isEmpty()) { return Collections.emptySet(); } try { log.debug("Waiting for " + POLLING_INTERVAL + " seconds."); Thread.sleep(POLLING_INTERVAL * 1000); } catch (InterruptedException e) { // Why would this happen? Anyway, stop waiting. return Collections.singleton("Polling was interrupted"); } elapsedSeconds += POLLING_INTERVAL; if (elapsedSeconds >= maximumWait) { return threadNames; } } }
From source file:org.apache.tuscany.sca.binding.rest.provider.RESTBindingInvoker.java
private RestClient createRestClient(HttpClient httpClient) { ClientConfig config = new ApacheHttpClientConfig(httpClient); // configureBasicAuth(config, userName, password); config.applications(new Application() { @Override//ww w.j a v a2 s.c o m public Set<Class<?>> getClasses() { return Collections.emptySet(); } @Override public Set<Object> getSingletons() { Set<Object> providers = new HashSet<Object>(); providers.add(new DataBindingJAXRSReader(registry)); providers.add(new DataBindingJAXRSWriter(registry)); return providers; } }); config.readTimeout(binding.getReadTimeout()); RestClient client = new RestClient(config); // Default to GET for RPC httpMethod = HttpMethod.GET; for (Map.Entry<Class<?>, String> e : mapping.entrySet()) { if (operation.getAttributes().get(e.getKey()) != null) { httpMethod = e.getValue(); break; } } if (operation.getOutputType() != null && !operation.getOutputType().getLogical().isEmpty()) { responseType = operation.getOutputType().getLogical().get(0).getPhysical(); } else { responseType = null; } return client; }
From source file:ca.sqlpower.object.SPSimpleVariableResolver.java
public Collection<Object> matches(String key, String partialValue) { // Call the subclass hook. this.beforeLookups(key); String namespace = SPVariableHelper.getNamespace(key); if (this.resolvesNamespace(namespace)) { Set<Object> matches = new HashSet<Object>(); Collection<Object> values = this.resolveCollection(key); for (Object obj : values) { String stringRep = obj.toString(); if (stringRep.startsWith(partialValue)) { matches.add(obj);/* w w w . jav a 2 s . com*/ } } return matches; } return Collections.emptySet(); }