List of usage examples for java.util Collections singleton
public static <T> Set<T> singleton(T o)
From source file:springfox.documentation.spring.web.dummy.controllers.EnumService.java
@RequestMapping(value = "/collection", method = RequestMethod.GET) @ApiOperation(value = "Example with response entity collection") public ResponseEntity<Set<EnumType>> getResponseEntityCollection() { return new ResponseEntity<Set<EnumType>>(Collections.singleton(EnumType.ONE), HttpStatus.OK); }
From source file:org.fenixedu.bennu.converters.BeanConverterService.java
@Override public Set<ConvertiblePair> getConvertibleTypes() { return Collections.singleton(new ConvertiblePair(String.class, IBean.class)); }
From source file:com.example.server.user.CustomUserDetailsService.java
private org.springframework.security.core.userdetails.User createUser(User account) { return new org.springframework.security.core.userdetails.User(account.getUsername(), account.getPassword(), Collections.singleton(createAuthority(account))); }
From source file:com.redhat.red.offliner.ftest.ChecksumMismatchFTest.java
@Test public void run() throws Exception { // We only need one repo server. TestRepositoryServer server = newRepositoryServer(); // Generate some test content byte[] expectedContent = contentGenerator.newBinaryContent(1024); byte[] downloadedContent = contentGenerator.newBinaryContent(1024); TrackedContentEntryDTO dto = contentGenerator.newRemoteContentEntry(new StoreKey(StoreType.remote, "test"), "jar", server.getBaseUri(), expectedContent); TrackedContentDTO record = new TrackedContentDTO(new TrackingKey("test-record"), Collections.emptySet(), Collections.singleton(dto)); String path = dto.getPath();/* w w w. j av a 2s . co m*/ // Register the generated content by writing it to the path within the repo server's dir structure. // This way when the path is requested it can be downloaded instead of returning a 404. server.registerContent(path, downloadedContent); server.registerContent(path + Main.SHA_SUFFIX, sha1Hex(downloadedContent)); server.registerContent(path + Main.MD5_SUFFIX, md5Hex(downloadedContent)); // Write the plaintext file we'll use as input. File foloRecord = temporaryFolder.newFile("folo." + getClass().getSimpleName() + ".json"); FileUtils.write(foloRecord, objectMapper.writeValueAsString(record)); Options opts = new Options(); opts.setBaseUrls(Collections.singletonList(server.getBaseUri())); // Capture the downloads here so we can verify the content. File downloads = temporaryFolder.newFolder(); opts.setDownloads(downloads); opts.setLocations(Collections.singletonList(foloRecord.getAbsolutePath())); Main main = run(opts); assertThat("Wrong number of downloads logged. Should have been just the checksum files.", main.getDownloaded(), equalTo(2)); assertThat("Checksum mismatch should have resulted in an error", main.getErrors().isEmpty(), equalTo(false)); assertThat("The downloaded file should not have been kept.", new File(downloads, path).exists(), equalTo(false)); }
From source file:biz.c24.io.spring.http.C24HttpMessageConverterUnitTests.java
@Test public void cannotConvertNonMatchingMediaType() { C24HttpMessageConverter converter = new C24HttpMessageConverter(model, Collections.singleton(new DataFormat(Type.TEXT))); assertThat(converter.canRead(CustomerLocal.class, MediaType.APPLICATION_XML), is(false)); }
From source file:com.opengamma.financial.analytics.PositionWeightFromNAVFunction.java
@Override public Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target) { return Collections.singleton(new ValueSpecification(ValueRequirementNames.WEIGHT, target.toSpecification(), createValueProperties().get())); }
From source file:com.ctriposs.rest4j.tools.idlgen.DocletDocsProvider.java
@Override public Set<String> supportedFileExtensions() { return Collections.singleton(".java"); }
From source file:com.bennavetta.appsite.util.DatastoreConfig.java
@Override public boolean containsKey(String key) { if (cache.getIfPresent(key) != null) return true; //save a trip to the datastore if possible return !datastore.get(Collections.singleton(KeyFactory.createKey(ENTITY, key))).isEmpty(); }
From source file:edu.pitt.dbmi.ccd.queue.service.JobQueueService.java
public List<AlgorithmJob> createJobQueueList(String username) { List<AlgorithmJob> listItems = new ArrayList<>(); UserAccount userAccount = userAccountService.findByUsername(username); List<JobQueueInfo> listJobs = jobQueueInfoService.findByUserAccounts(Collections.singleton(userAccount)); listJobs.forEach(job -> {/*from w ww .ja va2 s . com*/ AlgorithmJob algorithmJob = JobQueueUtility.convertJobEntity2JobModel(job); listItems.add(algorithmJob); }); return listItems; }
From source file:org.elasticsearch.client.benchmark.rest.RestClientBenchmark.java
@Override protected RestClient client(String benchmarkTargetHost) { return RestClient.builder(new HttpHost(benchmarkTargetHost, 9200)) .setHttpClientConfigCallback(b -> b.setDefaultHeaders( Collections.singleton(new BasicHeader(HttpHeaders.ACCEPT_ENCODING, "gzip")))) .setRequestConfigCallback(b -> b.setContentCompressionEnabled(true)).build(); }