Example usage for java.util List of

List of usage examples for java.util List of

Introduction

In this page you can find the example usage for java.util List of.

Prototype

static <E> List<E> of(E e1, E e2) 

Source Link

Document

Returns an unmodifiable list containing two elements.

Usage

From source file:com.spotify.helios.client.EndpointsTest.java

@Test
public void testUnableToResolve() throws Exception {
    final DnsResolver resolver = mock(DnsResolver.class);
    when(resolver.resolve("example.com")).thenThrow(new UnknownHostException());
    when(resolver.resolve("example.net")).thenThrow(new UnknownHostException());
    final List<Endpoint> endpoints = Endpoints.of(uris, resolver);

    assertThat(endpoints.size(), equalTo(0));
}

From source file:com.spotify.helios.client.EndpointsTest.java

@Test
public void testFactory() throws Exception {
    final DnsResolver resolver = mock(DnsResolver.class);
    when(resolver.resolve("example.com")).thenReturn(IPS_1);
    when(resolver.resolve("example.net")).thenReturn(IPS_2);
    final List<Endpoint> endpoints = Endpoints.of(uris, resolver);

    assertThat(endpoints.size(), equalTo(4));
    assertThat(endpoints.get(0).getUri(), equalTo(uri1));
    assertThat(endpoints.get(0).getIp(), equalTo(IP_A));
    assertThat(endpoints.get(1).getUri(), equalTo(uri1));
    assertThat(endpoints.get(1).getIp(), equalTo(IP_B));
    assertThat(endpoints.get(2).getUri(), equalTo(uri2));
    assertThat(endpoints.get(2).getIp(), equalTo(IP_C));
    assertThat(endpoints.get(3).getUri(), equalTo(uri2));
    assertThat(endpoints.get(3).getIp(), equalTo(IP_D));
}

From source file:com.spotify.helios.client.EndpointsTest.java

@Test
public void testSupplierFactory() throws Exception {
    final DnsResolver resolver = mock(DnsResolver.class);
    when(resolver.resolve("example.com")).thenReturn(IPS_1);
    when(resolver.resolve("example.net")).thenReturn(IPS_2);
    final Supplier<List<URI>> uriSupplier = Suppliers.ofInstance(uris);
    final Supplier<List<Endpoint>> endpointSupplier = Endpoints.of(uriSupplier, resolver);
    final List<Endpoint> endpoints = endpointSupplier.get();

    assertThat(endpoints.size(), equalTo(4));
    assertThat(endpoints.get(0).getUri(), equalTo(uri1));
    assertThat(endpoints.get(0).getIp(), equalTo(IP_A));
    assertThat(endpoints.get(1).getUri(), equalTo(uri1));
    assertThat(endpoints.get(1).getIp(), equalTo(IP_B));
    assertThat(endpoints.get(2).getUri(), equalTo(uri2));
    assertThat(endpoints.get(2).getIp(), equalTo(IP_C));
    assertThat(endpoints.get(3).getUri(), equalTo(uri2));
    assertThat(endpoints.get(3).getIp(), equalTo(IP_D));
}