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.gargoylesoftware.htmlunit.util.DebuggingWebConnectionTest.java

/**
 * @throws Exception if the test fails//from  w w  w . j  a  v a  2 s  .  c  om
 */
@Test
public void nameValueListToJsMap() throws Exception {
    assertEquals("{}", DebuggingWebConnection.nameValueListToJsMap(null));
    final List<NameValuePair> emptyList = Collections.emptyList();
    assertEquals("{}", DebuggingWebConnection.nameValueListToJsMap(emptyList));

    List<NameValuePair> list = Collections.singletonList(new NameValuePair("name", "value"));
    assertEquals("{'name': 'value'}", DebuggingWebConnection.nameValueListToJsMap(list));

    list = Collections.singletonList(new NameValuePair("na me", "value"));
    assertEquals("{'na me': 'value'}", DebuggingWebConnection.nameValueListToJsMap(list));

    list = new ArrayList<>();
    list.add(new NameValuePair("na me", "value1"));
    list.add(new NameValuePair("key", "value 2"));
    list.add(new NameValuePair("key 2", "value 3"));
    list.add(new NameValuePair("key 4", "with ' quote")); // can it really happen in header?
    final String expected = "{'na me': 'value1', 'key': 'value 2', 'key 2': 'value 3', 'key 4': 'with \\' quote'}";
    assertEquals(expected, DebuggingWebConnection.nameValueListToJsMap(list));
}

From source file:com.evolveum.midpoint.repo.sql.helpers.NameResolutionHelper.java

public void resolveNamesIfRequested(Session session, PrismContainerValue<?> containerValue,
        Collection<SelectorOptions<GetOperationOptions>> options) {
    resolveNamesIfRequested(session, Collections.singletonList(containerValue), options);
}

From source file:com.cognifide.aet.validation.impl.ValidationUtilsTest.java

@Before
public void setUp() throws Exception {
    when(builderWithErrors.hasErrors()).thenReturn(true);
    when(builderWithErrors.getErrorMessages()).thenReturn(Collections.singletonList(errorMessage));
    when(errorMessage.getMessage()).thenReturn("message");

    when(builderWithoutErrors.hasErrors()).thenReturn(false);
}

From source file:com.consol.citrus.admin.converter.action.ws.AssertSoapFaultContainerConverter.java

@Override
public TestAction convert(AssertFaultModel model) {
    TestAction action = new TestAction(getActionType(), getSourceModelClass());
    addActionProperties(action, model);//  www .j av a  2  s  . co m

    if (model.getWhen() != null) {
        action.setActions(getNestedActions(Collections.singletonList(getNestedAction(model))));
    }

    return action;
}

From source file:com.arpnetworking.tsdcore.sinks.ReMetSinkTest.java

@Test
public void testSerialize() throws IOException {
    final AggregatedData datum = TestBeanFactory.createAggregatedData();
    final List<AggregatedData> data = Collections.singletonList(datum);
    final ReMetSink remetSink = _remetSinkBuilder.build();
    final Collection<String> serializedData = remetSink.serialize(data, Collections.<Condition>emptyList());
    remetSink.close();//from   w  w w .j a  v a2 s.  c om

    Assert.assertEquals(1, serializedData.size());
    final JsonNode jsonArrayNode = OBJECT_MAPPER.readTree(Iterables.getOnlyElement(serializedData));
    Assert.assertTrue(jsonArrayNode.isArray());
    Assert.assertEquals(1, jsonArrayNode.size());
    final JsonNode jsonNode = jsonArrayNode.get(0);
    assertJsonEqualsDatum(jsonNode, datum);
}

From source file:com.epam.ta.reportportal.core.configs.ExternalSystemsConfiguration.java

@Bean
public RestTemplate restTemplate() {
    RestTemplate restTemplate = new RestTemplate(
            Collections.singletonList(new MappingJackson2HttpMessageConverter()));
    restTemplate.setErrorHandler(new ForwardingClientExceptionHandler());
    return restTemplate;
}

From source file:com.photon.phresco.service.admin.actions.admin.RoleList.java

public String save() {
    S_LOGGER.debug("Entering Method RolesList.save()");
    try {/*  w  ww .  j  a v a 2 s  .co  m*/
        if (validateForm()) {
            setErrorFound(true);
            return SUCCESS;
        }
        addActionMessage(getText(ROLE_ADDED, Collections.singletonList(name)));

    } catch (Exception e) {
        addActionError(getText(ROLE_NOT_ADDED, Collections.singletonList(name)));
    }
    return ADMIN_ROLE_LIST;

}

From source file:com.etsy.arbiter.ArbiterTest.java

@Test
public void testReadConfigFiles() throws IOException {
    File tempFile = writeToTempFile("testconfig.yaml");
    String[] configFiles = { tempFile.getAbsolutePath() };

    List<Config> result = Arbiter.readConfigFiles(configFiles, false);
    assertEquals(1, result.size());/*from  ww w.j ava2 s  .co m*/

    Config expected = new Config();
    expected.setKillName("kill");
    expected.setKillMessage("message");
    ActionType expectedTestAction = new ActionType();
    expected.setActionTypes(Collections.singletonList(expectedTestAction));

    expectedTestAction.setTag("testaction");
    expectedTestAction.setName("test");
    expectedTestAction.setXmlns("uri:oozie:test-action:0.1");
    Map<String, List<String>> defaultArgs = new HashMap<>();
    defaultArgs.put("a", Lists.newArrayList("a", "b", "c"));
    expectedTestAction.setDefaultArgs(defaultArgs);
    Map<String, String> properties = new HashMap<>();
    properties.put("p1", "v1");
    properties.put("p2", "v2");
    expectedTestAction.setConfigurationPosition(1);
    expectedTestAction.setProperties(properties);

    assertEquals(expected, result.get(0));
}

From source file:org.cloudfoundry.identity.uaa.authentication.manager.ScopeAuthenticationManagerTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    authenticationManager = new ScopeAuthenticationManager();
    authenticationManager.setThrowOnNotAuthenticated(true);
    authenticationManager.setRequiredScopes(Collections.singletonList("oauth.login"));
    clientCredentials = new HashMap<>();
    clientCredentials.put("client_id", "login");
    clientCredentials.put("grant_type", "client_credentials");
    clientCredentials.put("scope", "oauth.login,oauth.approval");
    request = new DefaultAuthorizationRequest(clientCredentials);
}

From source file:com.stormpath.shiro.spring.boot.autoconfigure.StormpathShiroAutoConfigurationTestApplication.java

/**
 * Override the default to block outbound requests.
 * @return a mock client/*from  w  w w.  jav  a2  s.  c o m*/
 */
@Bean
@SuppressWarnings("Duplicates")
public Client stormpathClient() {

    String appHref = "http://test-app-href";

    Application application = EasyMock.createMock(Application.class);
    Collection<Application> applications = Collections.singletonList(application);
    ApplicationList applicationList = EasyMock.createMock(ApplicationList.class);
    Client client = EasyMock.createNiceMock(Client.class);

    expect(applicationList.iterator()).andReturn(applications.iterator());
    expect(application.getName()).andReturn("test-app");
    expect(application.getHref()).andReturn(appHref);

    expect(client.getApplications()).andReturn(applicationList);
    expect(client.getResource(anyString(), eq(Application.class))).andReturn(application).anyTimes();

    replay(application, applicationList, client);

    return client;
}