ReservationStep { void checkResourceAvailablility( Map<Peer, UsedNetworkResources> reservedNetResources, String containerSubnet ) throws EnvironmentModificationException { for ( Map.Entry<Peer, UsedNetworkResources> peerReservedNetResourcesEntry : reservedNetResources.entrySet() ) { Peer peer = peerReservedNetResourcesEntry.getKey(); UsedNetworkResources netResources = peerReservedNetResourcesEntry.getValue(); if ( netResources.containerSubnetExists( containerSubnet ) ) { throw new EnvironmentModificationException( String.format( "Container subnet %s is already used on peer %s", environment.getSubnetCidr(), peer.getName() ) ); } if ( netResources.p2pSubnetExists( environment.getP2pSubnet() ) ) { throw new EnvironmentModificationException( String.format( "P2P subnet %s is already used on peer %s", environment.getP2pSubnet(), peer.getName() ) ); } if ( netResources.vniExists( environment.getVni() ) ) { throw new EnvironmentModificationException( String.format( "Vni %d is already used on peer %s", environment.getVni(), peer.getName() ) ); } } } ReservationStep( final Topology topology, final LocalEnvironment environment, final PeerManager peerManager,
                            final IdentityManager identityManager, final TrackerOperation trackerOperation ); void execute();  }
@Test public void testCheckResourceAvailablility() throws Exception { Map<Peer, UsedNetworkResources> map = Maps.newHashMap(); UsedNetworkResources resources = mock( UsedNetworkResources.class ); map.put( TestHelper.PEER(), resources ); step.checkResourceAvailablility( map, TestHelper.SUBNET_CIDR ); verify( resources ).vniExists( anyLong() ); }