RadixNetworkState { public Map<RadixNode, RadixNodeState> getNodeStates() { return nodes; } RadixNetworkState(Map<RadixNode, RadixNodeState> nodes); static RadixNetworkState of(RadixNode node, RadixNodeState state); Map<RadixNode, RadixNodeState> getNodeStates(); Set<RadixNode> getNodes(); @Override String toString();  }
@Test public void when_node_map_from_network_state_is_modified__then_exception_is_thrown() { RadixNetworkState state = new RadixNetworkState(new HashMap<>()); Map<RadixNode, RadixNodeState> nodeMap = state.getNodeStates(); assertThatThrownBy(() -> nodeMap.put(mock(RadixNode.class), mock(RadixNodeState.class))) .isInstanceOf(UnsupportedOperationException.class); }
@Test public void when_initial_empty_node_map_for_network_state_is_modified__then_nodes_from_network_state_should_remain_empty() { Map<RadixNode, RadixNodeState> initialMap = new HashMap<>(); RadixNetworkState state = new RadixNetworkState(initialMap); initialMap.put(mock(RadixNode.class), mock(RadixNodeState.class)); assertThat(state.getNodeStates()).isEmpty(); }