Example usage for java.util Collections singletonList

List of usage examples for java.util Collections singletonList

Introduction

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

Prototype

public static <T> List<T> singletonList(T o) 

Source Link

Document

Returns an immutable list containing only the specified object.

Usage

From source file:com.netflix.spinnaker.echo.artifacts.DockerHubArtifactExtractor.java

@Override
public List<Artifact> getArtifacts(String source, Map payload) {
    WebhookEvent webhookEvent = objectMapper.convertValue(payload, WebhookEvent.class);
    Repository repository = webhookEvent.getRepository();
    PushData pushData = webhookEvent.getPushData();
    if (repository == null || pushData == null) {
        log.warn("Malformed push data from dockerhub: {}", payload);
        return Collections.emptyList();
    }//ww w.  ja  v  a  2s  .co m

    String name = String.format("index.docker.io/%s", repository.getRepoName());
    String version = pushData.getTag();
    Map<String, Object> metadata = new ImmutableMap.Builder<String, Object>()
            .put("pusher", pushData.getPusher() != null ? pushData.getPusher() : "").build();

    return Collections.singletonList(
            Artifact.builder().type("docker/image").reference(String.format("%s:%s", name, version)).name(name)
                    .version(version).provenance(webhookEvent.getCallbackUrl()).metadata(metadata).build());
}

From source file:io.undertow.server.security.BasicAuthenticationTestCase.java

@Override
protected List<AuthenticationMechanism> getTestMechanisms() {
    AuthenticationMechanism mechanism = getTestMechanism();

    return Collections.singletonList(mechanism);
}

From source file:ch.cyberduck.core.ftp.FTPPathTest.java

@Test
public void test3243() {
    FTPFileEntryParser parser = new FTPParserFactory().createFileEntryParser("UNIX");

    FTPPath path = (FTPPath) PathFactory.createPath(
            SessionFactory.createSession(new Host(Protocol.FTP, "localhost")), "/SunnyD", Path.DIRECTORY_TYPE);
    assertEquals("SunnyD", path.getName());
    assertEquals("/SunnyD", path.getAbsolute());

    final AttributedList<Path> list = new AttributedList<Path>();
    final boolean success = path.parseListResponse(list, parser,
            Collections.singletonList(" drwxrwx--x 1 owner group          512 Jun 12 15:40 SunnyD"));

    assertFalse(success);/*from  w w w .  ja  va  2  s  . c  om*/
    assertTrue(list.isEmpty());
}

From source file:com.todo.backend.security.UserDetailsServiceImpl.java

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

    log.trace(".loadUserByUsername({})", username);

    final String lowercaseUsername = username.toLowerCase();
    final Optional<User> optionalUser = userRepository.findByUsername(lowercaseUsername);

    if (!optionalUser.isPresent()) {
        throw new UsernameNotFoundException("User " + username + " not found!");
    }//w  ww  .j  a  va  2s.  c om

    final User user = optionalUser.get();
    final List<GrantedAuthority> grantedAuthorities = Collections
            .singletonList(new SimpleGrantedAuthority(user.getRole().name()));
    return new org.springframework.security.core.userdetails.User(lowercaseUsername, null, grantedAuthorities);
}

From source file:me.smoe.adar.zookeeper.zookeeper.Zookeeper.java

public static void createNodeWithAuth(ZooKeeper zooKeeper, String path, String username, String password)
        throws KeeperException, InterruptedException, NoSuchAlgorithmException {
    ACL acl = new ACL(Perms.READ | Perms.WRITE | Perms.CREATE | Perms.DELETE,
            new Id("digest", DigestAuthenticationProvider.generateDigest(username + ":" + password)));

    zooKeeper.create(path, path.getBytes(), Collections.singletonList(acl), CreateMode.PERSISTENT);
}

From source file:com.aerospike.servicebroker.service.AerospikeCatalogService.java

@Override
public Catalog getCatalog() {
    return new Catalog(Collections.singletonList(getServiceDefinition()));
}

From source file:de.tud.inf.db.sparqlytics.olap.ResetFilterTest.java

@Test
public void testRun() {
    ResetFilter instance = new ResetFilter("dim1", "lev1");
    Session session = new Session();
    CubeBuilder builder = new CubeBuilder(new ElementTriplesBlock(BasicPattern.wrap(
            Collections.singletonList(Triple.createMatch(NodeFactory.createVariable("test"), null, null)))))
                    .addMeasure(new DummyMeasure("mes1"));
    Dimension dim1 = new DummyDimension("dim1");
    Level lev1 = dim1.getLevels().get(0);
    session.setCube(builder.addDimension(dim1).build(""));
    Filter filter = new Filter(Var.alloc("test"), NodeValue.TRUE);
    session.addFilter(dim1, lev1, filter);
    Map<Pair<Dimension, Level>, Filter> filters = session.getFilters();
    Assert.assertEquals(1, filters.size());
    Map.Entry<Pair<Dimension, Level>, Filter> entry = filters.entrySet().iterator().next();
    Pair<Dimension, Level> key = entry.getKey();
    Assert.assertSame(dim1, key.getLeft());
    Assert.assertSame(lev1, key.getRight());
    Assert.assertSame(filter, entry.getValue());
    session.execute(instance);/*from w w  w .  j av  a 2s  .  co  m*/
    Assert.assertTrue(session.getFilters().isEmpty());
}

From source file:com.jaspersoft.jasperserver.api.engine.jasperreports.domain.impl.CompositeReportExecutionListener.java

private static List<ReportExecutionListener> list(ReportExecutionListener listener) {
    if (listener == null) {
        return Collections.<ReportExecutionListener>emptyList();
    }// ww  w  .j a  v a  2s.co m

    if (listener instanceof CompositeReportExecutionListener) {
        return ((CompositeReportExecutionListener) listener).listeners;
    }

    return Collections.singletonList(listener);
}

From source file:com.weebly.opus1269.copyeverywhere.cloud.DeviceGroups.java

/**
 * Add to Device Group - blocks, call off main thread
 *
 * @param idToken authorization token/*  ww w . ja  va  2s .  c  o  m*/
 * @return message on error, otherwise empty string
 */
public static String add(String idToken) {

    String errorMessage = "";
    final String keyName = Prefs.getPersonEmail();

    try {

        final String regId = getGcmToken();

        // Headers
        final HttpRequest request = new HttpRequest();
        request.setHeader(HttpRequest.HEADER_PROJECT_ID, GcmConstants.PROJECT_ID);
        request.setHeader(HttpRequest.HEADER_CONTENT_TYPE, HttpRequest.CONTENT_TYPE_JSON);
        request.setHeader(HttpRequest.HEADER_ACCEPT, HttpRequest.CONTENT_TYPE_JSON);

        // Request
        final JSONObject data = new JSONObject();
        data.put(GcmConstants.OPERATION, "add");
        data.put(GcmConstants.NOTIFICATION_KEY_NAME, keyName);
        data.put(GcmConstants.REGISTRATION_IDS, new JSONArray(Collections.singletonList(regId)));
        data.put(GcmConstants.ID_TOKEN, idToken);

        request.doPost(GcmConstants.URL, data.toString());

        final int responseCode = request.getResponseCode();
        final JSONObject response = new JSONObject(request.getResponseBody());
        if (responseCode == 200) {
            // success
            final String notificationKey = response.getString(GcmConstants.NOTIFICATION_KEY);
            AppUtils.log(TAG, GcmConstants.LOG_NOTIFICATION_KEY + notificationKey);
            storeValues(true, regId, notificationKey, keyName);
        } else {
            errorMessage = response.toString(4);
            Log.e(TAG, errorMessage);
            storeValues(false, "", "", keyName);
        }

    } catch (IOException | JSONException e) {
        errorMessage = e.getMessage() + "\n" + e;
        Log.e(TAG, "Error adding Device Group token: " + errorMessage);
        storeValues(false, "", "", keyName);
    }

    return errorMessage;
}

From source file:be.fedict.eid.idp.sp.protocol.saml2.artifact.ArtifactProxySelector.java

/**
 * {@inheritDoc}/*  w  w w.ja  v  a  2 s  . c  om*/
 */
@Override
public List<Proxy> select(URI uri) {
    LOG.debug("select: " + uri);
    String hostname = uri.getHost();
    Proxy proxy = this.proxies.get(hostname);
    if (null != proxy) {
        LOG.debug("using proxy: " + proxy);
        return Collections.singletonList(proxy);
    }
    return this.defaultProxySelector.select(uri);
}