List of usage examples for java.util Collections singleton
public static <T> Set<T> singleton(T o)
From source file:org.cloudfoundry.identity.uaa.login.ProfileControllerTests.java
public void testGet() { 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.get(model);/*w w w.ja v a 2s . c om*/ assertTrue(model.containsAttribute("links")); assertTrue(model.containsAttribute("approvals")); }
From source file:cop.raml.processor.AbstractProcessorTest.java
protected static boolean runAnnotationProcessor(File dir) throws URISyntaxException { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); Set<JavaFileObject> compilationUnits = new LinkedHashSet<>(); for (File file : (List<File>) FileUtils.listFiles(dir, JAVA_FILE_FILTER, DirectoryFileFilter.INSTANCE)) compilationUnits.add(new SimpleJavaFileObjectImpl(file, JavaFileObject.Kind.SOURCE)); List<String> options = new ArrayList<>(); // options.put("-Apackages=com.bosch"); // options.put("-AfilterRegex=AnalysisController"); // options.put("-Aversion=0.8"); options.add("-d"); options.add("target"); JavaCompiler.CompilationTask task = compiler.getTask(null, null, null, options, null, compilationUnits); task.setProcessors(Collections.singleton(new RestProcessor())); return task.call(); }
From source file:com.icfcc.cache.interceptor.CacheOperation.java
public void setCacheName(String cacheName) { Assert.hasText(cacheName); this.cacheNames = Collections.singleton(cacheName); }
From source file:com.sugoi_wada.AndroidPublisherHelper.java
private static Credential authorizeWithServiceAccount(String serviceAccountEmail, File p12) throws GeneralSecurityException, IOException { log.info(String.format("Authorizing using Service Account: %s", serviceAccountEmail)); // Build service account credential. GoogleCredential credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY).setServiceAccountId(serviceAccountEmail) .setServiceAccountScopes(Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER)) .setServiceAccountPrivateKeyFromP12File(p12).build(); return credential; }
From source file:lux.index.field.AttributeTextField.java
@Override public Iterable<IndexableField> getFieldValues(XmlIndexer indexer) { XdmNode doc = indexer.getXdmNode();/*from ww w. j av a 2 s . c o m*/ if (doc != null && doc.getUnderlyingNode() != null) { SaxonDocBuilder builder = indexer.getSaxonDocBuilder(); Analyzer analyzer = getAnalyzer(); TokenStream textTokens = null; try { textTokens = analyzer.tokenStream(getName(), new CharSequenceReader("")); } catch (IOException e) { } AttributeTokenStream tokens = new AttributeTokenStream(getName(), analyzer, textTokens, doc, builder.getOffsets(), indexer.getProcessor()); return new FieldValues(this, Collections.singleton(new TextField(getName(), tokens))); } return Collections.emptySet(); }
From source file:io.undertow.servlet.test.session.ServletURLRewritingSessionTestCase.java
@BeforeClass public static void setup() { DeploymentUtils.setupServlet(new ServletExtension() { @Override//from w w w .j ava 2 s .c om public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { deploymentInfo.setServletSessionConfig(new ServletSessionConfig() .setSessionTrackingModes(Collections.singleton(SessionTrackingMode.URL))); } }, Servlets.servlet(URLRewritingServlet.class).addMapping("/foo")); }
From source file:com.github.thorbenlindhauer.cluster.ep.TruncatedGaussianPotentialResolverTest.java
@Test public void testTwoSidedTruncatedGaussianApproximation() { ContinuousVariable variable = new ContinuousVariable("A"); Scope scope = new Scope(Collections.singleton(variable)); GaussianFactor factor = StandaloneGaussiaFactorBuilder.withVariables(variable).scope("A").momentForm() .parameters(new ArrayRealVector(new double[] { 2.0d }), new Array2DRowRealMatrix(new double[] { 4.0d })); TruncatedGaussianPotentialResolver resolver = new TruncatedGaussianPotentialResolver(variable, 0.5d, 6.0d); FactorSet<GaussianFactor> factorSet = new FactorSet<GaussianFactor>(Collections.singleton(factor)); FactorSet<GaussianFactor> approximation = resolver.project(factorSet, scope); assertThat(approximation.getFactors()).hasSize(1); GaussianFactor approximationFactor = approximation.getFactors().iterator().next(); RealVector meanVector = approximationFactor.getMeanVector(); RealMatrix covarianceMatrix = approximationFactor.getCovarianceMatrix(); assertThat(meanVector.getDimension()).isEqualTo(1); assertThat(meanVector.getEntry(0)).isEqualTo(2.658510664d, TestConstants.DOUBLE_VALUE_TOLERANCE); assertThat(covarianceMatrix.isSquare()); assertThat(covarianceMatrix.getColumnDimension()).isEqualTo(1); assertThat(covarianceMatrix.getEntry(0, 0)).isEqualTo(1.787386921d, TestConstants.DOUBLE_VALUE_TOLERANCE); }
From source file:io.fabric8.spring.boot.converters.FactoryConverter.java
@Override public Set<ConvertiblePair> getConvertibleTypes() { return Collections.singleton(new ConvertiblePair(sourceType, targetType)); }
From source file:org.fenixedu.bennu.spring.DomainObjectConverter.java
@Override public Set<ConvertiblePair> getConvertibleTypes() { return Collections.singleton(new ConvertiblePair(String.class, DomainObject.class)); }
From source file:ch.rasc.downloadchart.Application.java
@Bean public ServletRegistrationBean downloadChartServletRegistration() { ServletRegistrationBean reg = new ServletRegistrationBean(); reg.setUrlMappings(Collections.singleton("/downloadchart")); reg.setServlet(new DownloadChartServlet()); return reg;/* w w w.j a v a 2s .c o m*/ }