List of usage examples for java.util Collections singleton
public static <T> Set<T> singleton(T o)
From source file:net.sourceforge.fenixedu.domain.phd.email.PhdProgramEmailBean.java
public AndPredicate<PhdIndividualProgramProcess> getManagedPhdProgramsPredicate() { final AndPredicate<PhdIndividualProgramProcess> result = new AndPredicate<PhdIndividualProgramProcess>(); if (getPhdProgram() != null) { result.add(new InlinePredicate<PhdIndividualProgramProcess, PhdProgram>(getPhdProgram()) { @Override//from w w w .j a va 2 s .co m public boolean eval(PhdIndividualProgramProcess toEval) { if (toEval.getPhdProgram() != null) { return getValue().equals(toEval.getPhdProgram()); } else if (toEval.getPhdProgramFocusArea() != null) { return !CollectionUtils.intersection(Collections.singleton(getValue()), toEval.getPhdProgramFocusArea().getPhdProgramsSet()).isEmpty(); } else { return false; } } }); } return result; }
From source file:com.vmware.photon.controller.deployer.dcp.workflow.ProvisionHostWorkflowServiceTest.java
public static ProvisionHostWorkflowService.State buildValidStartState(@Nullable TaskState.TaskStage startStage, @Nullable ProvisionHostWorkflowService.TaskState.SubStage startSubStage) { ProvisionHostWorkflowService.State startState = new ProvisionHostWorkflowService.State(); startState.vibPath = "VIB_PATH"; startState.deploymentServiceLink = "DEPLOYMENT_SERVICE_LINK"; startState.hostServiceLink = "HOST_SERVICE_LINK"; startState.chairmanServerList = new HashSet<>(Collections.singleton("localhost:13000")); startState.controlFlags = ControlFlags.CONTROL_FLAG_OPERATION_PROCESSING_DISABLED; if (null != startStage) { startState.taskState = new ProvisionHostWorkflowService.TaskState(); startState.taskState.stage = startStage; startState.taskState.subStage = startSubStage; }// w w w . j a v a 2 s .c o m return startState; }
From source file:com.flipkart.flux.controller.WorkFlowExecutionControllerTest.java
@Test public void testEventPost_shouldLookupRouterAndSendMessage() throws Exception { final EventData testEventData = new EventData("event1", "foo", "someStringData", "runtime"); when(eventsDAO.findBySMIdAndName(1l, "event1")) .thenReturn(new Event("event1", "foo", Event.EventStatus.pending, 1l, null, null)); EventData[] expectedEvents = new EventData[] { new EventData("event1", "someType", "someStringData", "runtime") }; when(eventsDAO.findByEventNamesAndSMId(Collections.singleton("event1"), 1l)) .thenReturn(Arrays.asList(expectedEvents)); when(eventsDAO.findTriggeredEventsNamesBySMId(1l)).thenReturn(Collections.singletonList("event1")); workFlowExecutionController.postEvent(testEventData, 1l, null); verify(routerRegistry, times(2)).getRouter("com.flipkart.flux.dao.TestWorkflow_testTask"); // For 2 unblocked states mockActor.underlyingActor().assertMessageReceived(new TaskAndEvents("testTask", "com.flipkart.flux.dao.TestWorkflow_testTask_event1", 2L, expectedEvents, 1l, objectMapper.writeValueAsString(TestUtils.standardStateMachineOutputEvent()), 2), 1); mockActor.underlyingActor().assertMessageReceived(new TaskAndEvents("testTask", "com.flipkart.flux.dao.TestWorkflow_testTask_event1", 3L, expectedEvents, 1l, null, 2), 1); verifyNoMoreInteractions(routerRegistry); }
From source file:com.yahoo.elide.jsonapi.JsonApiTest.java
@Test public void writeSingle() throws JsonProcessingException { Parent parent = new Parent(); Child child = new Child(); parent.setId(123L);//from w w w.java 2s.co m child.setId(2); parent.setChildren(Collections.singleton(child)); parent.setFirstName("bob"); child.setParents(Collections.singleton(parent)); child.setFriends(new HashSet<>()); JsonApiDocument jsonApiDocument = new JsonApiDocument(); jsonApiDocument.setData(new Data<>(new PersistentResource<>(parent, userScope).toResource())); String expected = "{\"data\":{\"type\":\"parent\",\"id\":\"123\",\"attributes\":{\"firstName\":\"bob\"},\"relationships\":{\"children\":{\"data\":[{\"type\":\"child\",\"id\":\"2\"}]},\"spouses\":{\"data\":[]}}}}"; String doc = mapper.writeJsonApiDocument(jsonApiDocument); assertEquals(doc, expected); }
From source file:com.opengamma.financial.analytics.LastHistoricalValueFunction.java
@Override public Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target) { return Collections.singleton( new ValueSpecification(_requirementName, target.toSpecification(), createValueProperties().get())); }
From source file:edu.pitt.dbmi.ccd.db.service.JobQueueInfoService.java
public JobQueueInfo findByIdAndUseraccount(Long id, UserAccount userAccount) { return jobQueueInfoRepository.findByIdAndUserAccounts(id, Collections.singleton(userAccount)); }
From source file:io.lavagna.config.DispatcherServletInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); // initialize cookie if (StringUtils.isNotEmpty(System.getProperty(CookieNames.PROPERTY_NAME))) { CookieNames.updatePrefix(System.getProperty(CookieNames.PROPERTY_NAME)); }/*from w w w. j av a 2 s .co m*/ // //definition order = execution order, the first executed filter is HSTSFilter addFilter(servletContext, "HSTSFilter", HSTSFilter.class, "/*"); addFilter(servletContext, "CSFRFilter", CSFRFilter.class, "/*"); addFilter(servletContext, "RememberMeFilter", RememberMeFilter.class, "/*"); addFilter(servletContext, "AnonymousUserFilter", AnonymousUserFilter.class, "/*"); addFilter(servletContext, "SecurityFilter", SecurityFilter.class, "/*"); addFilter(servletContext, "ETagFilter", ShallowEtagHeaderFilter.class, "*.js", "*.css", // "/", "/project/*", "/admin/*", "/me/", // "*.html", "*.woff", "*.eot", "*.svg", "*.ttf"); addFilter(servletContext, "GzipFilter", GzipFilter.class, "*.js", "*.css", // "/", "/project/*", "/admin/*", "/me/", // "/api/self", "/api/board/*", "/api/project/*"); servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE)); servletContext.getSessionCookieConfig().setHttpOnly(true); servletContext.getSessionCookieConfig().setName(CookieNames.getSessionCookieName()); }
From source file:org.wallride.autoconfigure.WebAdminComponentScanRegistrar.java
private Set<String> getPackagesToScan(AnnotationMetadata metadata) { AnnotationAttributes attributes = AnnotationAttributes .fromMap(metadata.getAnnotationAttributes(WebAdminComponentScan.class.getName())); String[] value = attributes.getStringArray("value"); String[] basePackages = attributes.getStringArray("basePackages"); Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses"); if (!ObjectUtils.isEmpty(value)) { Assert.state(ObjectUtils.isEmpty(basePackages), "@WebAdminComponentScan basePackages and value attributes are mutually exclusive"); }//from w w w . java2 s . co m Set<String> packagesToScan = new LinkedHashSet<String>(); packagesToScan.addAll(Arrays.asList(value)); packagesToScan.addAll(Arrays.asList(basePackages)); for (Class<?> basePackageClass : basePackageClasses) { packagesToScan.add(ClassUtils.getPackageName(basePackageClass)); } if (packagesToScan.isEmpty()) { return Collections.singleton(ClassUtils.getPackageName(metadata.getClassName())); } return packagesToScan; }
From source file:com.devicehive.defects.Defect157NotificationTest.java
@Before public void prepareNotifications() { DeviceClassEquipmentVO equipment = DeviceFixture.createEquipmentVO(); DeviceClassUpdate deviceClass = DeviceFixture.createDeviceClass(); deviceClass.setEquipment(Optional.of(Collections.singleton(equipment))); NetworkVO network = DeviceFixture.createNetwork(); DeviceUpdate deviceUpdate = DeviceFixture.createDevice(guid); deviceUpdate.setDeviceClass(Optional.of(deviceClass)); deviceUpdate.setNetwork(Optional.of(network)); // register device Response response = performRequest("/device/" + guid, "PUT", emptyMap(), singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), deviceUpdate, NO_CONTENT, null);//from www .j a v a 2s. c o m assertNotNull(response); { DeviceNotification notification = createDeviceNotification("c1"); notification = performRequest("/device/" + guid + "/notification", "POST", emptyMap(), singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), notification, CREATED, DeviceNotification.class); assertNotNull(notification.getId()); } { DeviceNotification notification = createDeviceNotification("c2"); notification = performRequest("/device/" + guid + "/notification", "POST", emptyMap(), singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), notification, CREATED, DeviceNotification.class); assertNotNull(notification.getId()); } { DeviceNotification notification = createDeviceNotification("c3"); notification = performRequest("/device/" + guid + "/notification", "POST", emptyMap(), singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), notification, CREATED, DeviceNotification.class); assertNotNull(notification.getId()); } }
From source file:io.galeb.router.tests.mocks.HttpClientConfigurationMock.java
@Bean HttpClient httpClientService() {/*from ww w.ja va 2 s . co m*/ logger.warn("Using " + this); return new HttpClient() { @Override public void getResponseBody(String url, String etag, OnCompletedCallBack callBack) { if (url != null && url.startsWith(SystemEnv.MANAGER_URL.getValue() + "/virtualhostscached/")) { Environment environment = new Environment("desenv"); environment.getProperties().put(FULLHASH_PROP, UUID.randomUUID().toString()); Project project = new Project("projectX"); VirtualHost virtuahost = new VirtualHost("test.com", environment, project); Map<String, String> virtualhostProperties = new HashMap<>(); virtualhostProperties.put(IPACL_ALLOW, "127.0.0.0/8,0:0:0:0:0:0:0:1/128,10.*.*.*,172.*.*.*"); virtualhostProperties.put(FULLHASH_PROP, "xxxxxxxxxx"); virtuahost.setProperties(virtualhostProperties); RuleType ruleType = new RuleType(EnumRuleType.PATH.toString()); Pool pool = new Pool("pool_test"); Target target = new Target("http://127.0.0.1:8080"); Map<String, String> targetProperties = new HashMap<>(); targetProperties.put(PROP_HEALTHY.value(), OK.toString()); target.setProperties(targetProperties); pool.setTargets(Collections.singleton(target)); BalancePolicyType balancePolicyTypeRR = new BalancePolicyType( HostSelectorLookup.ROUNDROBIN.toString()); BalancePolicy balancePolicyRR = new BalancePolicy(HostSelectorLookup.ROUNDROBIN.toString(), balancePolicyTypeRR); pool.setBalancePolicy(balancePolicyRR); Rule rule_slash = new Rule("rule_test_slash", ruleType, pool); Map<String, String> ruleProperties = new HashMap<>(); ruleProperties.put(RULE_MATCH, "/"); ruleProperties.put(RULE_ORDER, Integer.toString(Integer.MAX_VALUE - 1)); rule_slash.setProperties(ruleProperties); Rule other_rule = new Rule("other_rule", ruleType, pool); Map<String, String> otherRuleProperties = new HashMap<>(); otherRuleProperties.put(RULE_MATCH, "/search"); otherRuleProperties.put(RULE_ORDER, "0"); other_rule.setProperties(otherRuleProperties); virtuahost.setRules(new HashSet<>(Arrays.asList(rule_slash, other_rule))); ManagerClient.Virtualhosts virtualhostsFromManager = new ManagerClient.Virtualhosts(); virtualhostsFromManager.virtualhosts = new VirtualHost[1]; virtualhostsFromManager.virtualhosts[0] = virtuahost; callBack.onCompleted(new Gson().toJson(virtualhostsFromManager)); } } @Override public void post(String url, String etag) { logger.info("sending POST to Manager (ignored) with etag " + etag); } }; }