Datasource { private Datasource(final String node, final int port, final String resource) { this.node = node; this.port = port; this.resource = resource; } private  Datasource(final String node,
                       final int port,
                       final String resource); static List<Datasource> datasources(final String ds); @JsonCreator static Datasource datasource(final String ds); static Datasource datasource(final String node,
                                        final int port,
                                        final String resource); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); final String node; final int port; final String resource; }
@Test public void shouldBuildDatasourceFromStringWithoutPort() { final Datasource testee = datasource("foo/bar"); assertThat(testee.node).isEqualTo("foo"); assertThat(testee.port).isEqualTo(-1); assertThat(testee.resource).isEqualTo("bar"); }
@Test public void shouldBuildDatasourceFromStringWithoutPortAndResource() { final Datasource testee = datasource("foo"); assertThat(testee.node).isEqualTo("foo"); assertThat(testee.port).isEqualTo(-1); assertThat(testee.resource).isEqualTo(""); }
@Test public void shouldBuildDatasource() { final Datasource testee = datasource("foo", 42, "bar"); assertThat(testee.node).isEqualTo("foo"); assertThat(testee.port).isEqualTo(42); assertThat(testee.resource).isEqualTo("bar"); }
@Test public void shouldBuildDatasourceFromString() { final Datasource testee = datasource("foo:42/bar"); assertThat(testee.node).isEqualTo("foo"); assertThat(testee.port).isEqualTo(42); assertThat(testee.resource).isEqualTo("bar"); }
@Test public void shouldBuildDatasourceFromString2() { final Datasource testee = datasource("foo:42/bar:foobar/0815"); assertThat(testee.node).isEqualTo("foo"); assertThat(testee.port).isEqualTo(42); assertThat(testee.resource).isEqualTo("bar:foobar/0815"); }