Example usage for java.util Collections singleton

List of usage examples for java.util Collections singleton

Introduction

In this page you can find the example usage for java.util Collections singleton.

Prototype

public static <T> Set<T> singleton(T o) 

Source Link

Document

Returns an immutable set containing only the specified object.

Usage

From source file:io.pravega.test.integration.MultiReadersEndToEndTest.java

@Test(timeout = 30000)
public void testReadersGreaterThanSegments() throws Exception {
    runTest(Collections.singleton("teststream3"), 3, 2);
    runTestUsingMock(Collections.singleton("teststream3"), 3, 2);
}

From source file:com.jayway.maven.plugins.android.common.AndroidPublisherHelper.java

private static Credential authorizeWithServiceAccount(String serviceAccountEmail, File pk12File)
        throws GeneralSecurityException, IOException {
    LOG.info(String.format("Authorizing using Service Account: %s", serviceAccountEmail));

    // Build service account credential.
    GoogleCredential credential = new GoogleCredential.Builder().setTransport(httpTransport)
            .setJsonFactory(JSON_FACTORY).setServiceAccountId(serviceAccountEmail)
            .setServiceAccountScopes(Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
            .setServiceAccountPrivateKeyFromP12File(
                    pk12File == null ? new File(SRC_RESOURCES_KEY_P12) : pk12File)
            .build();//from w w w  .j  a va2 s.c  o  m
    return credential;
}

From source file:org.openmrs.module.kenyaemr.reporting.builder.hiv.DecliningCd4ReportBuilderTest.java

@Test
public void testReport() throws Exception {
    Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV);

    // Enrol patient #7 in the HIV program
    TestUtils.enrollInProgram(TestUtils.getPatient(7), hivProgram, new Date());

    // Give patient #7 a CD4 count 180 days ago
    Concept cd4 = Dictionary.getConcept(Dictionary.CD4_COUNT);
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, -180);
    TestUtils.saveObs(TestUtils.getPatient(7), cd4, 123d, calendar.getTime());

    // Give patient #7 a lower CD4 now
    TestUtils.saveObs(TestUtils.getPatient(7), cd4, 120d, new Date());

    Context.flushSession();//from  ww  w . j ava2s.c om

    // Evaluate report
    ReportDefinition rd = reportBuilder.build(report);
    EvaluationContext ec = new EvaluationContext();

    ReportData data = Context.getService(ReportDefinitionService.class).evaluate(rd, ec);

    ReportingTestUtils.checkStandardCohortReport(Collections.singleton(7), data);
    //ReportingTestUtils.printReport(data);
}

From source file:com.cloudera.oryx.app.als.FeatureVectorsTest.java

@Test
public void testRecent() {
    FeatureVectors fv = new FeatureVectors();
    fv.setVector("foo", new float[] { 1.0f });
    Collection<String> recentIDs = new HashSet<>();
    fv.addAllRecentTo(recentIDs);//from  ww w.  j av  a  2s. com
    assertEquals(Collections.singleton("foo"), recentIDs);
    fv.retainRecentAndIDs(Collections.singleton("foo"));
    recentIDs.clear();
    fv.addAllRecentTo(recentIDs);
    assertEquals(0, recentIDs.size());
}

From source file:auto.parse.processor.AutoParseProcessor.java

@Override
public Set<String> getSupportedAnnotationTypes() {
    return Collections.singleton(AutoParse.class.getName());
}

From source file:org.gvnix.addon.web.mvc.addon.MvcOperationsImpl.java

public void setup() {
    // Get add-on configuration file
    Element configuration = XmlUtils.getConfiguration(getClass());

    // Install the add-on repository needed
    List<Element> repos = XmlUtils.findElements("/configuration/gvnix/repositories/repository", configuration);
    for (Element repo : repos) {
        getProjectOperations().addRepositories(getProjectOperations().getFocusedModuleName(),
                Collections.singleton(new Repository(repo)));
    }/*  www . j  av a 2 s . c o  m*/

    // Install dependencies
    List<Element> depens = XmlUtils.findElements("/configuration/gvnix/dependencies/dependency", configuration);

    DependenciesVersionManager.manageDependencyVersion(getMetadataService(), getProjectOperations(), depens);
}

From source file:ddf.catalog.validation.impl.validator.ISO3CountryCodeValidator.java

private AttributeValidationReport buildReport(Attribute attribute) {
    AttributeValidationReportImpl report = new AttributeValidationReportImpl();

    attribute.getValues().stream().filter(String.class::isInstance).map(String.class::cast)
            .map(ignoreCase ? String::toUpperCase : String::toString).filter(s -> !countryCodes.contains(s))
            .map(s -> new ValidationViolationImpl(Collections.singleton(attribute.getName()),
                    s + " is not a valid ISO_3166-1 Alpha3 country code.", ValidationViolation.Severity.ERROR))
            .forEach(report::addViolation);

    countryCodes.forEach(report::addSuggestedValue);

    return report;
}

From source file:gda.data.scan.datawriter.scannablewriter.NumberComponentWriter.java

@Override
public Collection<SelfCreatingLink> makeComponent(final NeXusFileInterface file, final int[] dim,
        final String path, final String scannableName, final String componentName, final Object pos,
        final String unit) throws NexusException {

    final String name = enterLocation(file, path);

    try {/* ww  w. ja v  a 2 s.c om*/
        file.opendata(name);
        LOGGER.info("found dataset " + path + " exists already when trying to create it for " + scannableName
                + ". This may not be a problem provided the data written is the same");
        leaveLocation(file);
        return null;

    } catch (final NexusException e) {
        // this is normal case!
    }

    final int[] makedatadim = makedatadimfordim(dim);
    file.makedata(name, NexusFile.NX_FLOAT64, makedatadim.length, makedatadim);
    file.opendata(name);

    if (componentName != null) {
        file.putattr("local_name", (scannableName + "." + componentName).getBytes(UTF8), NexusFile.NX_CHAR);
    }

    final StringBuilder axislist = new StringBuilder(dim.length * 3 + 1).append('1');
    for (int j = 2; j <= dim.length; j++) {
        axislist.append(',').append(j);
    }
    file.putattr("axis", axislist.toString().getBytes(UTF8), NexusFile.NX_CHAR);

    if (StringUtils.isNotBlank(unit)) {
        file.putattr("units", unit.getBytes(UTF8), NexusFile.NX_CHAR);
    }

    addCustomAttributes(file, scannableName, componentName);
    file.putslab(getComponentSlab(pos), nulldimfordim(dim), slabsizedimfordim(dim));

    final SelfCreatingLink scl = new SelfCreatingLink(file.getdataID());

    file.closedata();
    leaveLocation(file);

    return Collections.singleton(scl);
}

From source file:edu.cornell.mannlib.vitro.webapp.auth.identifier.common.CommonIdentifierBundleFactory.java

/**
 * Create an identifier that shows the role level of the current user, or
 * PUBLIC if the user is not logged in./*from   ww  w .  j a  v  a  2  s.c o m*/
 */
private Collection<? extends Identifier> createRoleLevelIdentifiers(HttpServletRequest req) {
    RoleLevel roleLevel = RoleLevel.getRoleFromLoginStatus(req);
    return Collections.singleton(new HasRoleLevel(roleLevel));
}

From source file:org.keycloak.adapters.springsecurity.client.KeycloakClientRequestFactoryTest.java

@Test(expected = IllegalStateException.class)
public void testGetKeycloakSecurityContextInvalidAuthentication() throws Exception {
    SecurityContextHolder.getContext().setAuthentication(new PreAuthenticatedAuthenticationToken("foo", "bar",
            Collections.singleton(new KeycloakRole("baz"))));
    factory.getKeycloakSecurityContext();
}