@Test public void shouldReturnArrayWhenUsersOrPath() { ZKAddressParser mock = Mockito.mock(ZKAddressParser.class); String add1 = "192.168.0.1:2182"; String add2 = "192.168.0.2:2183"; String concat = add1 + "," + add2; List<ZKAddress> dummyReturn = new ArrayList<>(1); dummyReturn.add(new ZKAddress(add1 + "/mesos")); dummyReturn.add(new ZKAddress("bob:pass@" + add2)); Mockito.when(mock.validateZkUrl(anyString())).thenReturn(dummyReturn); ZKFormatter formatter = new MesosStateZKFormatter(mock); String address = formatter.format(""); assertEquals(concat, address); }
public String format(String zkUrl) { List<ZKAddress> addressList = parser.validateZkUrl(zkUrl); StringBuilder builder = new StringBuilder(); addressList.forEach(add -> builder.append(",").append(add.getAddress()).append(":").append(add.getPort())); builder.deleteCharAt(0); return builder.toString(); }
MesosStateZKFormatter extends AbstractZKFormatter { public String format(String zkUrl) { List<ZKAddress> addressList = parser.validateZkUrl(zkUrl); StringBuilder builder = new StringBuilder(); addressList.forEach(add -> builder.append(",").append(add.getAddress()).append(":").append(add.getPort())); builder.deleteCharAt(0); return builder.toString(); } }
MesosStateZKFormatter extends AbstractZKFormatter { public String format(String zkUrl) { List<ZKAddress> addressList = parser.validateZkUrl(zkUrl); StringBuilder builder = new StringBuilder(); addressList.forEach(add -> builder.append(",").append(add.getAddress()).append(":").append(add.getPort())); builder.deleteCharAt(0); return builder.toString(); } MesosStateZKFormatter(ZKAddressParser parser); }
MesosStateZKFormatter extends AbstractZKFormatter { public String format(String zkUrl) { List<ZKAddress> addressList = parser.validateZkUrl(zkUrl); StringBuilder builder = new StringBuilder(); addressList.forEach(add -> builder.append(",").append(add.getAddress()).append(":").append(add.getPort())); builder.deleteCharAt(0); return builder.toString(); } MesosStateZKFormatter(ZKAddressParser parser); String format(String zkUrl); }
MesosStateZKFormatter extends AbstractZKFormatter { public String format(String zkUrl) { List<ZKAddress> addressList = parser.validateZkUrl(zkUrl); StringBuilder builder = new StringBuilder(); addressList.forEach(add -> builder.append(",").append(add.getAddress()).append(":").append(add.getPort())); builder.deleteCharAt(0); return builder.toString(); } MesosStateZKFormatter(ZKAddressParser parser); String format(String zkUrl);  }