import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import com.google.common.collect.ImmutableList;
+
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import com.google.common.collect.ImmutableList;
-
public class NeutronSubnetAwareDataStoreTest extends NeutronMapperDataBrokerTest {
- private static final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
- private static final Uuid networkUuid = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
- private static final Uuid subnetUuid = new Uuid("cccccccc-cccc-cccc-cccc-cccccccccccc");
- private static final Uuid subnetUuid2 = new Uuid("cccccccc-cccc-cccc-cccc-ccccccccccc2");
- private static final IpAddress ipAddress = new IpAddress(new Ipv4Address("10.0.0.2"));
- private static final IpAddress ipAddress2 = new IpAddress(new Ipv4Address("10.0.2.2"));
- private static final IpPrefix ipPrefix = new IpPrefix(new Ipv4Prefix("10.0.0.0/24"));
+ private static final Uuid TENANT_UUID = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
+ private static final Uuid NETWORK_UUID = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
+ private static final Uuid SUBNET_UUID = new Uuid("cccccccc-cccc-cccc-cccc-cccccccccccc");
+ private static final Uuid SUBNET_UUID_2 = new Uuid("cccccccc-cccc-cccc-cccc-ccccccccccc2");
+ private static final IpAddress IP_ADDRESS = new IpAddress(new Ipv4Address("10.0.0.2"));
+ private static final IpAddress IP_ADDRESS_2 = new IpAddress(new Ipv4Address("10.0.2.2"));
+ private static final IpPrefix IP_PREFIX = new IpPrefix(new Ipv4Prefix("10.0.0.0/24"));
private DataBroker dataBroker;
private Neutron neutron;
private RpcResult<Void> rpcResult;
private RpcResult<Void> rpcFail;
private NeutronSubnetAware subnetAware;
- private static final Subnet subnet = new SubnetBuilder().setTenantId(tenantUuid)
- .setUuid(subnetUuid)
+ private static final Subnet SUBNET = new SubnetBuilder().setTenantId(TENANT_UUID)
+ .setUuid(SUBNET_UUID)
.setName("subnetName")
- .setNetworkId(networkUuid)
- .setGatewayIp(ipAddress)
- .setCidr(ipPrefix)
+ .setNetworkId(NETWORK_UUID)
+ .setGatewayIp(IP_ADDRESS)
+ .setCidr(IP_PREFIX)
.build();
- private static final Subnet subnet2 = new SubnetBuilder().setTenantId(tenantUuid)
- .setUuid(subnetUuid2)
+ private static final Subnet SUBNET_2 = new SubnetBuilder().setTenantId(TENANT_UUID)
+ .setUuid(SUBNET_UUID_2)
.setName("subnetName2")
- .setNetworkId(networkUuid)
- .setGatewayIp(ipAddress2)
- .setCidr(ipPrefix)
+ .setNetworkId(NETWORK_UUID)
+ .setGatewayIp(IP_ADDRESS_2)
+ .setCidr(IP_PREFIX)
.build();
@Before
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public void init() throws ExecutionException, InterruptedException {
futureRpcResult = mock(Future.class);
rpcResult = mock(RpcResult.class);
NetworkProviderExtension networkProviderExtension =
new NetworkProviderExtensionBuilder().setPhysicalNetwork("physicalNetwork").build();
- Network network = new NetworkBuilder().setUuid(networkUuid)
+ Network network = new NetworkBuilder().setUuid(NETWORK_UUID)
.addAugmentation(NetworkProviderExtension.class, networkProviderExtension)
.build();
Networks networks = new NetworksBuilder().setNetwork(ImmutableList.of(network)).build();
when(neutron.getNetworks()).thenReturn(networks);
- subnetAware.onCreated(subnet, neutron);
+ subnetAware.onCreated(SUBNET, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
}
@Test
Networks networks = new NetworksBuilder().setNetwork(ImmutableList.of()).build();
when(neutron.getNetworks()).thenReturn(networks);
- subnetAware.onCreated(subnet, neutron);
+ subnetAware.onCreated(SUBNET, neutron);
- NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
}
@Test
public void testOnUpdated() {
- Network network = new NetworkBuilder().setUuid(networkUuid).build();
+ Network network = new NetworkBuilder().setUuid(NETWORK_UUID).build();
Networks networks = new NetworksBuilder().setNetwork(ImmutableList.of(network)).build();
when(neutron.getNetworks()).thenReturn(networks);
- subnetAware.onCreated(subnet, neutron);
+ subnetAware.onCreated(SUBNET, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet, neutron, null);
- NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, tenantUuid, subnet2, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, TENANT_UUID, SUBNET_2, neutron, null);
- subnetAware.onUpdated(subnet, subnet2, neutron, neutron);
+ subnetAware.onUpdated(SUBNET, SUBNET_2, neutron, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet2, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET_2, neutron, null);
}
@Test
public void testOnDeleted() {
- Network network = new NetworkBuilder().setUuid(networkUuid).build();
+ Network network = new NetworkBuilder().setUuid(NETWORK_UUID).build();
Networks networks = new NetworksBuilder().setNetwork(ImmutableList.of(network)).build();
when(neutron.getNetworks()).thenReturn(networks);
- subnetAware.onCreated(subnet, neutron);
+ subnetAware.onCreated(SUBNET, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
- subnetAware.onDeleted(subnet, neutron, neutron);
+ subnetAware.onDeleted(SUBNET, neutron, neutron);
- NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
}
+
@Test
public void testOnDeleted_wrongSubnet() {
- Network network = new NetworkBuilder().setUuid(networkUuid).build();
+ Network network = new NetworkBuilder().setUuid(NETWORK_UUID).build();
Networks networks = new NetworksBuilder().setNetwork(ImmutableList.of(network)).build();
when(neutron.getNetworks()).thenReturn(networks);
- subnetAware.onCreated(subnet, neutron);
+ subnetAware.onCreated(SUBNET, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
- subnetAware.onDeleted(subnet2, neutron, neutron);
+ subnetAware.onDeleted(SUBNET_2, neutron, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
}
}