Cluster implements Contextual { @SuppressWarnings("rawtypes") public Map<String, Object> toMap() { Map<String, Object> map = new LinkedHashMap<String, Object>(); map.put("stripes", stripeStream().sorted(Comparator.comparing(AbstractNode::getId)).map(Stripe::toMap).collect(Collectors.toList())); map.put("clients", clientStream().sorted(Comparator.comparing(AbstractNode::getId)).map(Client::toMap).collect(Collectors.toList())); return map; } private  Cluster(); boolean isEmpty(); Stream<Client> clientStream(); Stream<Stripe> stripeStream(); Map<String, Client> getClients(); int getClientCount(); Map<String, Stripe> getStripes(); int getStripeCount(); Stripe getSingleStripe(); boolean addClient(Client client); Optional<Client> getClient(Context context); Optional<Client> getClient(ClientIdentifier clientIdentifier); Optional<Client> getClient(String id); Optional<Client> removeClient(String id); boolean addStripe(Stripe stripe); Optional<Stripe> getStripe(Context context); Optional<Stripe> getStripe(String id); Optional<Stripe> removeStripe(String id); Optional<ServerEntity> getActiveServerEntity(Context context); Optional<ServerEntity> getServerEntity(Context context); Optional<Server> getServer(Context context); List<? extends Node> getNodes(Context context); String getPath(Context context); Stream<ServerEntity> serverEntityStream(); Stream<ServerEntity> activeServerEntityStream(); Stream<Server> serverStream(); @Override Context getContext(); @Override void setContext(Context context); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @SuppressWarnings("rawtypes") Map<String, Object> toMap(); static Cluster create();  }
@Test @SuppressWarnings("rawtypes") public void test_toMap() throws Exception { String expectedJson = new String(Files.readAllBytes(new File("src/test/resources/cluster.json").toPath()), "UTF-8"); Map actual = cluster1.toMap(); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); JSONAssert.assertEquals(expectedJson, mapper.writeValueAsString(actual), true); }