List of usage examples for java.util Collections singleton
public static <T> Set<T> singleton(T o)
From source file:org.fcrepo.auth.xacml.PDPFactory.java
/** * Make a PDP for the Fedora environment. * * @see org.springframework.beans.factory.FactoryBean#getObject() * @return the PDP//w w w . ja v a2s . c o m */ public PDP makePDP() { final PolicyFinder policyFinder = new PolicyFinder(); policyFinder.setModules(Collections.singleton(fedoraPolicyFinderModule)); final ResourceFinder resourceFinder = new ResourceFinder(); resourceFinder.setModules(Collections.singletonList(fedoraResourceFinderModule)); final PDPConfig pdpConfig = new PDPConfig(new AttributeFinder(), policyFinder, resourceFinder); final PDP pdp = new PDP(pdpConfig); LOGGER.info("XACML Policy Decision Point (PDP) initialized"); return pdp; }
From source file:net.sourceforge.fenixedu.presentationTier.util.CollectionFilter.java
public CollectionFilter(Predicate predicate, Comparator<T> comparator) { this(Collections.singleton(predicate), comparator); }
From source file:be.ordina.msdashboard.graph.RedisServiceTest.java
@Test public void getAllNodes() { Set<String> keys = Collections.singleton("nodeId"); doReturn(keys).when(redisTemplate).keys("virtual:*"); ValueOperations opsForValue = mock(ValueOperations.class); doReturn(opsForValue).when(redisTemplate).opsForValue(); Node node = new Node("redisnode"); doReturn(node).when(opsForValue).get("nodeId"); Collection<Node> nodes = redisService.getAllNodes(); verify(redisTemplate).keys("virtual:*"); verify(redisTemplate).opsForValue(); verify(opsForValue).get("nodeId"); assertThat(nodes).isNotEmpty();/*from w w w .j ava2 s. c om*/ assertThat(nodes.stream().findFirst().get()).isEqualTo(node); }
From source file:org.cloudfoundry.identity.uaa.login.ProfileControllerTests.java
public void testPostForUpdate() { controller.setLinks(Collections.singletonMap("foo", "http://example.com")); Mockito.when(restTemplate.getForObject(approvalsUri, Set.class)) .thenReturn(Collections.singleton(Collections.singletonMap("clientId", "foo"))); Model model = new ExtendedModelMap(); controller.post(Collections.singleton("read"), "", null, "foo", model); assertTrue(model.containsAttribute("links")); assertTrue(model.containsAttribute("approvals")); }
From source file:net.logstash.logback.composite.loggingevent.TagsJsonProviderTest.java
@Before public void setup() { when(marker1.hasReferences()).thenReturn(true); when(marker1.iterator()).thenReturn(Collections.<Marker>singleton(marker2).iterator()); when(marker2.hasReferences()).thenReturn(true); when(marker2.iterator()).thenReturn(Collections.singleton(marker3).iterator()); when(marker3.hasReferences()).thenReturn(true); when(marker3.iterator()).thenReturn(Collections.singleton(marker4).iterator()); when(marker1.getName()).thenReturn("marker1"); when(marker2.getName()).thenReturn("marker2"); when(marker3.getName()).thenReturn(JsonMessageJsonProvider.JSON_MARKER_NAME); when(marker4.getName()).thenReturn("marker4"); when(event.getMarker()).thenReturn(marker1); }
From source file:org.openmrs.module.kenyaemr.page.controller.EditProgramFormPageController.java
public String controller(@RequestParam("appId") String appId, @RequestParam("patientProgramId") PatientProgram enrollment, @RequestParam("formUuid") String formUuid, @RequestParam("returnUrl") String returnUrl) { Form form = Context.getFormService().getFormByUuid(formUuid); if (form == null) { throw new IllegalArgumentException("Cannot find form with uuid = " + formUuid); }//ww w . ja v a 2s. com Patient patient = enrollment.getPatient(); StringBuilder sb = new StringBuilder("redirect:" + EmrConstants.MODULE_ID + "/"); // Find encounter for this form within the enrollment. If there are more than one candidate, pick the last one List<Encounter> encounters = Context.getEncounterService().getEncounters(patient, null, enrollment.getDateEnrolled(), enrollment.getDateCompleted(), Collections.singleton(form), null, null, null, null, false); if (encounters.size() == 0) { sb.append("enterForm.page?formUuid=" + formUuid); } else { // in case there are more than one, we pick the last one Encounter encounter = encounters.get(encounters.size() - 1); sb.append("editForm.page?encounterId=" + encounter.getEncounterId()); } sb.append("&appId=" + appId); sb.append("&patientId=" + patient.getId()); sb.append("&returnUrl=" + java.net.URLEncoder.encode(returnUrl)); return sb.toString(); }
From source file:com.thesmartweb.swebrank.DataManipulation.java
/** * Method that clears a List from duplicates and null elements * @param wordList It contains the List to be cleared * @return a List cleared from duplicates and null elements *///from w w w . ja va 2s. c o m public List<String> clearListString(List<String> wordList) { //remove all null elements of the wordlist wordList.removeAll(Collections.singleton(null)); //remove the duplicate elements since HashSet does not allow duplicates HashSet<String> hashSet_wordList = new HashSet<String>(wordList); //create an iterator to the hashset to add the elements back to the wordlist Iterator wordList_iterator = hashSet_wordList.iterator(); //clear the wordlist wordList.clear(); while (wordList_iterator.hasNext()) { wordList.add(wordList_iterator.next().toString()); } return wordList; }
From source file:com.linkedin.pinot.core.indexsegment.mutable.MutableSegmentImplAggregateMetricsTest.java
@BeforeClass public void setUp() { Schema schema = new Schema.SchemaBuilder().setSchemaName("testSchema") .addSingleValueDimension(DIMENSION_1, FieldSpec.DataType.INT) .addSingleValueDimension(DIMENSION_2, FieldSpec.DataType.STRING) .addMetric(METRIC, FieldSpec.DataType.LONG).build(); _mutableSegmentImpl = MutableSegmentImplTestUtils.createMutableSegmentImpl(schema, Collections.singleton(METRIC), Collections.singleton(DIMENSION_1), true); }
From source file:eu.fusepool.deduplication.transformer.DuplicatesTransformer.java
@Override public Set<MimeType> getSupportedInputFormats() { try {/*from w ww. j a va 2 s . c o m*/ MimeType mimeType = new MimeType("text/plain;charset=UTF-8"); return Collections.singleton(mimeType); } catch (MimeTypeParseException ex) { throw new RuntimeException(ex); } }
From source file:com.example.server.user.CustomUserDetailsService.java
private Authentication authenticate(User account) { return new UsernamePasswordAuthenticationToken(createUser(account), null, Collections.singleton(createAuthority(account))); }