apply checkstyle check during build for neutron-mapper 15/64715/3
authorMichal Cmarada <mcmarada@cisco.com>
Wed, 25 Oct 2017 13:13:41 +0000 (15:13 +0200)
committerMichal Cmarada <mcmarada@cisco.com>
Wed, 25 Oct 2017 13:35:49 +0000 (15:35 +0200)
enabling checkstyle checks on build which should prevent
checkstyle violations in future.

Change-Id: Ibe476cc7aed6f6b9b65dd998245b6f0108eef31b
Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
46 files changed:
neutron-mapper/pom.xml
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/gbp/util/NeutronGbpIidFactory.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/EndpointRegistrator.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/NeutronMapper.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/infrastructure/MetadataService.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/infrastructure/NetworkClient.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/infrastructure/NetworkService.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/infrastructure/ServiceUtil.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronAware.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronFloatingIpAware.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronNetworkAware.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronPortAware.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronRouterAware.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronSecurityGroupAware.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronSubnetAware.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/NeutronGbpMapperServiceImpl.java [deleted file]
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/NeutronSecurityRuleAware.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/SecRuleEntityDecoder.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/SecRuleNameDecoder.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/SingleClassifierRule.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/SingleRuleContract.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/util/NetworkUtils.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/util/PortUtils.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/util/RouterUtils.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/util/SecurityGroupUtils.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/util/SecurityRuleUtils.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/util/SubnetUtils.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/util/Utils.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/gbp/util/NeutronGbpIidFactoryTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/NeutronMapperTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronNetworkAwareDataStoreTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronPortAwareDataStoreTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronRouterAwareDataStoreTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronSecurityGroupAwareDataStoreTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronSubnetAwareDataStoreTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/NeutronSecurityRuleAwareDataStoreTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/NeutronSecurityRuleAwareTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/SecRuleEntityDecoderTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/SecRuleNameDecoderTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/SingleClassifierRuleTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/test/ConfigDataStoreReader.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/test/CustomDataBrokerTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/test/NeutronEntityFactory.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/test/NeutronMapperAssert.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/test/NeutronMapperDataBrokerTest.java
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/test/PolicyAssert.java

index 167c0da1d30b89f35c850c5aa3210e53dea475fb..f24cc5cf6e6d7fce626540159335778d5e46d6c0 100644 (file)
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <excludes>org/opendaylight/yang/gen/**,**/yang/**</excludes>
+          <consoleOutput>true</consoleOutput>
+          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>check</goal>
+            </goals>
+            <phase>process-sources</phase>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 </project>
index 42232b0e3b2e25799460449f91f3d3ee5bb208a9..0a84688b32b46427e9090da83a6a14c668e1e45e 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.UniqueId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev170511.IpPrefixType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.rev160427.ContextType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.GbpByNeutronMappings;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.NeutronByGbpMappings;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.BaseEndpointsByPorts;
@@ -48,8 +49,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 public class NeutronGbpIidFactory {
 
     public static InstanceIdentifier<BaseEndpointByPort> baseEndpointByPortIid(UniqueId portId) {
-        return InstanceIdentifier.builder(
-                org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+        return InstanceIdentifier.builder(Mappings.class)
             .child(GbpByNeutronMappings.class)
             .child(BaseEndpointsByPorts.class)
             .child(BaseEndpointByPort.class, new BaseEndpointByPortKey(portId))
@@ -59,8 +59,7 @@ public class NeutronGbpIidFactory {
     @Deprecated
     public static InstanceIdentifier<EndpointByPort> endpointByPortIid(UniqueId portId) {
         return InstanceIdentifier
-            .builder(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+            .builder(Mappings.class)
             .child(GbpByNeutronMappings.class)
             .child(EndpointsByPorts.class)
             .child(EndpointByPort.class, new EndpointByPortKey(portId))
@@ -68,8 +67,7 @@ public class NeutronGbpIidFactory {
     }
 
     public static InstanceIdentifier<PortByBaseEndpoint> portByBaseEndpointIid(PortByBaseEndpointKey baseEpkey) {
-        return InstanceIdentifier.builder(
-                org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+        return InstanceIdentifier.builder(Mappings.class)
             .child(NeutronByGbpMappings.class)
             .child(PortsByBaseEndpoints.class)
             .child(PortByBaseEndpoint.class, baseEpkey)
@@ -79,8 +77,7 @@ public class NeutronGbpIidFactory {
     @Deprecated
     public static InstanceIdentifier<PortByEndpoint> portByEndpointIid(L2BridgeDomainId l2BdId, MacAddress mac) {
         return InstanceIdentifier
-            .builder(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+            .builder(Mappings.class)
             .child(NeutronByGbpMappings.class)
             .child(PortsByEndpoints.class)
             .child(PortByEndpoint.class, new PortByEndpointKey(l2BdId, mac))
@@ -94,8 +91,7 @@ public class NeutronGbpIidFactory {
                 IpPrefixType.class,
                 contextId,
                 contextType);
-        return InstanceIdentifier.builder(
-                org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+        return InstanceIdentifier.builder(Mappings.class)
             .child(NeutronByGbpMappings.class)
             .child(ExternalGatewaysAsEndpoints.class)
             .child(ExternalGatewayAsEndpoint.class, key)
@@ -106,8 +102,7 @@ public class NeutronGbpIidFactory {
     public static InstanceIdentifier<ExternalGatewayAsL3Endpoint> externalGatewayAsL3Endpoint(L3ContextId l3Context,
             IpAddress ipAddress) {
         return InstanceIdentifier
-            .builder(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+            .builder(Mappings.class)
             .child(NeutronByGbpMappings.class)
             .child(ExternalGatewaysAsL3Endpoints.class)
             .child(ExternalGatewayAsL3Endpoint.class, new ExternalGatewayAsL3EndpointKey(ipAddress, l3Context))
@@ -116,8 +111,7 @@ public class NeutronGbpIidFactory {
 
     public static InstanceIdentifier<ProviderPhysicalNetworkAsL2FloodDomain> providerPhysicalNetworkAsL2FloodDomainIid(
             TenantId tenantId, ContextId domainId) {
-        return InstanceIdentifier.builder(
-                org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+        return InstanceIdentifier.builder(Mappings.class)
             .child(NeutronByGbpMappings.class)
             .child(ProviderNetworksAsL2FloodDomains.class)
             .child(ProviderPhysicalNetworkAsL2FloodDomain.class,
@@ -126,10 +120,11 @@ public class NeutronGbpIidFactory {
     }
 
     @Deprecated
+    @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 static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.provider.physical.networks.as.l2.flood.domains.ProviderPhysicalNetworkAsL2FloodDomain> providerPhysicalNetworkAsL2FloodDomainIid(
             TenantId tenantId, L2FloodDomainId l2FdId) {
-        return InstanceIdentifier.builder(
-                org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+        return InstanceIdentifier.builder(Mappings.class)
             .child(NeutronByGbpMappings.class)
             .child(ProviderPhysicalNetworksAsL2FloodDomains.class)
             .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.provider.physical.networks.as.l2.flood.domains.ProviderPhysicalNetworkAsL2FloodDomain.class,
index 551a84357c4b93e3a74884a6fba1ca0684cd9e2f..5ecfd508e103d2215e495cef820b0861d5c01028 100644 (file)
@@ -8,12 +8,15 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper;
 
-import javax.annotation.Nullable;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
+
+import javax.annotation.Nullable;
+
 import org.opendaylight.groupbasedpolicy.neutron.mapper.util.MappingUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
@@ -71,43 +74,47 @@ public class EndpointRegistrator {
         }
     }
 
-    public boolean unregisterEndpoint(AddressEndpointUnreg addrEpUnreg) {
-        UnregisterEndpointInput input = new UnregisterEndpointInputBuilder().setAddressEndpointUnreg(
-                ImmutableList.<AddressEndpointUnreg>of(new AddressEndpointUnregBuilder().setKey(addrEpUnreg.getKey())
-                    .build())).build();
-        return unregisterEndpoint(input);
-    }
-
-    public boolean unregisterEndpoint(UnregisterEndpointInput input) {
+    @Deprecated
+    @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 boolean registerEndpoint(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput regEndpointInput) {
         try {
-            RpcResult<Void> rpcResult = baseEpService.unregisterEndpoint(input).get();
+            RpcResult<Void> rpcResult = epService.registerEndpoint(regEndpointInput).get();
             if (!rpcResult.isSuccessful()) {
-                LOG.warn("Illegal state - unregisterEndpoint was not successful. Input of RPC: {}", input);
+                LOG.warn("Illegal state - register Endpoint was not successful. Input of RPC: {}", regEndpointInput);
                 return false;
             }
             return true;
         } catch (InterruptedException | ExecutionException e) {
-            LOG.error("unregisterEndpoint failed. {}", input, e);
+            LOG.error("registerEndpoint failed. {}", regEndpointInput, e);
             return false;
         }
     }
 
-    @Deprecated
-    public boolean registerEndpoint(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput regEndpointInput) {
+    public boolean unregisterEndpoint(AddressEndpointUnreg addrEpUnreg) {
+        UnregisterEndpointInput input = new UnregisterEndpointInputBuilder().setAddressEndpointUnreg(
+            ImmutableList.<AddressEndpointUnreg>of(new AddressEndpointUnregBuilder().setKey(addrEpUnreg.getKey())
+                .build())).build();
+        return unregisterEndpoint(input);
+    }
+
+    public boolean unregisterEndpoint(UnregisterEndpointInput input) {
         try {
-            RpcResult<Void> rpcResult = epService.registerEndpoint(regEndpointInput).get();
+            RpcResult<Void> rpcResult = baseEpService.unregisterEndpoint(input).get();
             if (!rpcResult.isSuccessful()) {
-                LOG.warn("Illegal state - register Endpoint was not successful. Input of RPC: {}", regEndpointInput);
+                LOG.warn("Illegal state - unregisterEndpoint was not successful. Input of RPC: {}", input);
                 return false;
             }
             return true;
         } catch (InterruptedException | ExecutionException e) {
-            LOG.error("registerEndpoint failed. {}", regEndpointInput, e);
+            LOG.error("unregisterEndpoint failed. {}", input, e);
             return false;
         }
     }
 
     @Deprecated
+    @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 boolean unregisterEndpoint(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput unregEndpointInput) {
         try {
             RpcResult<Void> rpcResult = epService.unregisterEndpoint(unregEndpointInput).get();
@@ -154,17 +161,20 @@ public class EndpointRegistrator {
     }
 
     @Deprecated
+    @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 boolean registerL3EpAsExternalGateway(TenantId tenantId, IpAddress ipAddress, L3ContextId l3Context,
             NetworkDomainId networkContainment) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput registerEndpointInput =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder()
-                    .setL3Address(ImmutableList
-                        .of(new L3AddressBuilder().setL3Context(l3Context).setIpAddress(ipAddress).build()))
-                    .setTenant(tenantId)
-                    .setNetworkContainment(networkContainment)
-                    .setEndpointGroups(ImmutableList.of(MappingUtils.EPG_EXTERNAL_ID))
-                    .setTimestamp(System.currentTimeMillis())
-                    .build();
+        org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput
+            registerEndpointInput =
+            new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder()
+                .setL3Address(
+                    ImmutableList.of(new L3AddressBuilder().setL3Context(l3Context).setIpAddress(ipAddress).build()))
+                .setTenant(tenantId)
+                .setNetworkContainment(networkContainment)
+                .setEndpointGroups(ImmutableList.of(MappingUtils.EPG_EXTERNAL_ID))
+                .setTimestamp(System.currentTimeMillis())
+                .build();
         try {
             RpcResult<Void> rpcResult = epService.registerEndpoint(registerEndpointInput).get();
             if (!rpcResult.isSuccessful()) {
@@ -180,12 +190,13 @@ public class EndpointRegistrator {
     }
 
     @Deprecated
+    @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 boolean unregisterL3EpAsExternalGateway(IpAddress ipAddress, L3ContextId l3Context) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput unregisterEndpointInput =
+        org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput
+            unregisterEndpointInput =
             new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInputBuilder()
-                .setL3(ImmutableList.of(new L3Builder().setL3Context(l3Context)
-                    .setIpAddress(ipAddress)
-                    .build()))
+                .setL3(ImmutableList.of(new L3Builder().setL3Context(l3Context).setIpAddress(ipAddress).build()))
                 .build();
 
         try {
index da456032c19f63189996cadc455a0cabe201e536..35b39b7bef98d74b6e5c5b107799eb26dd6840e5 100644 (file)
@@ -7,6 +7,12 @@
  */
 package org.opendaylight.groupbasedpolicy.neutron.mapper;
 
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.PeekingIterator;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -60,37 +66,31 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
 
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.PeekingIterator;
-
 public class NeutronMapper implements ClusteredDataTreeChangeListener<Neutron>, AutoCloseable {
 
-    private static final String EXC_MSG_UNKNOWN_MODIFICATION_TYPE_WITHIN_DATA = "Unknown modification type within data ";
+    private static final String EXC_MSG_UNKNOWN_MODIFICATION_TYPE_IN_DATA = "Unknown modification type within data ";
 
-    private final static SecurityRuleBuilder EIG_INGRESS_IPV4_SEC_RULE_BUILDER = new SecurityRuleBuilder()
+    private static final SecurityRuleBuilder EIG_INGRESS_IPV4_SEC_RULE_BUILDER = new SecurityRuleBuilder()
         .setUuid(new Uuid("0a629f80-2408-11e6-b67b-9e71128cae77"))
         .setDirection(DirectionIngress.class)
         .setEthertype(EthertypeV4.class)
         .setSecurityGroupId(MappingUtils.EIG_UUID);
-    private final static SecurityRuleBuilder EIG_EGRESS_IPV4_SEC_RULE_BUILDER = new SecurityRuleBuilder()
+    private static final SecurityRuleBuilder EIG_EGRESS_IPV4_SEC_RULE_BUILDER = new SecurityRuleBuilder()
         .setUuid(new Uuid("0f1789be-2408-11e6-b67b-9e71128cae77"))
         .setDirection(DirectionEgress.class)
         .setEthertype(EthertypeV4.class)
         .setSecurityGroupId(MappingUtils.EIG_UUID);
-    private final static SecurityRuleBuilder EIG_INGRESS_IPV6_SEC_RULE_BUILDER = new SecurityRuleBuilder()
+    private static final SecurityRuleBuilder EIG_INGRESS_IPV6_SEC_RULE_BUILDER = new SecurityRuleBuilder()
         .setUuid(new Uuid("139b7f90-2408-11e6-b67b-9e71128cae77"))
         .setDirection(DirectionIngress.class)
         .setEthertype(EthertypeV6.class)
         .setSecurityGroupId(MappingUtils.EIG_UUID);
-    private final static SecurityRuleBuilder EIG_EGRESS_IPV6_SEC_RULE_BUILDER = new SecurityRuleBuilder()
+    private static final SecurityRuleBuilder EIG_EGRESS_IPV6_SEC_RULE_BUILDER = new SecurityRuleBuilder()
         .setUuid(new Uuid("17517202-2408-11e6-b67b-9e71128cae77"))
         .setDirection(DirectionEgress.class)
         .setEthertype(EthertypeV6.class)
         .setSecurityGroupId(MappingUtils.EIG_UUID);
-    private final static SecurityGroupBuilder EIG_SEC_GROUP_BUILDER =
+    private static final SecurityGroupBuilder EIG_SEC_GROUP_BUILDER =
             new SecurityGroupBuilder().setUuid(MappingUtils.EIG_UUID);
 
     private final NeutronNetworkAware networkAware;
@@ -148,16 +148,20 @@ public class NeutronMapper implements ClusteredDataTreeChangeListener<Neutron>,
                     findModifiedData(NeutronSecurityRuleAware.SECURITY_RULE_WILDCARD_IID, neutronModif);
             onDataObjectModification(secRuleModifs, securityRuleAware);
             // subnet
-            List<DataObjectModification<Subnet>> subnetModifs = findModifiedData(NeutronSubnetAware.SUBNET_WILDCARD_IID, neutronModif);
+            List<DataObjectModification<Subnet>> subnetModifs =
+                findModifiedData(NeutronSubnetAware.SUBNET_WILDCARD_IID, neutronModif);
             onDataObjectModification(subnetModifs, subnetAware);
             // port
-            List<DataObjectModification<Port>> portModifs = findModifiedData(NeutronPortAware.PORT_WILDCARD_IID, neutronModif);
+            List<DataObjectModification<Port>> portModifs =
+                findModifiedData(NeutronPortAware.PORT_WILDCARD_IID, neutronModif);
             onDataObjectModification(portModifs, portAware);
             // router
-            List<DataObjectModification<Router>> routerModifs = findModifiedData(NeutronRouterAware.ROUTER_WILDCARD_IID, neutronModif);
+            List<DataObjectModification<Router>> routerModifs =
+                findModifiedData(NeutronRouterAware.ROUTER_WILDCARD_IID, neutronModif);
             onDataObjectModification(routerModifs, routerAware);
             // floating IP
-            List<DataObjectModification<Floatingip>> floatingIpModifs = findModifiedData(NeutronFloatingIpAware.FLOATING_IP_WILDCARD_IID, neutronModif);
+            List<DataObjectModification<Floatingip>> floatingIpModifs =
+                findModifiedData(NeutronFloatingIpAware.FLOATING_IP_WILDCARD_IID, neutronModif);
             onDataObjectModification(floatingIpModifs, floatingIpAware);
         }
     }
@@ -169,15 +173,12 @@ public class NeutronMapper implements ClusteredDataTreeChangeListener<Neutron>,
             final T dataAfter = dataModif.getDataAfter();
             if (dataBefore == null && dataAfter != null) {
                 neutronAware.onCreated(dataAfter, neutronAfter);
-            }
-            else if (dataBefore != null && dataAfter != null) {
+            } else if (dataBefore != null && dataAfter != null) {
                 neutronAware.onUpdated(dataBefore, dataAfter, neutronBefore, neutronAfter);
-            }
-            else if (dataBefore != null) {
+            } else if (dataBefore != null) {
                 neutronAware.onDeleted(dataBefore, neutronBefore, neutronAfter);
-            }
-            else {
-                throw new IllegalStateException(EXC_MSG_UNKNOWN_MODIFICATION_TYPE_WITHIN_DATA + dataModif);
+            } else {
+                throw new IllegalStateException(EXC_MSG_UNKNOWN_MODIFICATION_TYPE_IN_DATA + dataModif);
             }
         }
     }
@@ -277,7 +278,7 @@ public class NeutronMapper implements ClusteredDataTreeChangeListener<Neutron>,
     /**
      * Finds all modified subnodes of given type in {@link Neutron} node.
      *
-     * @param <T>
+     * @param <T> dataObject type
      * @param iid path to data in root node
      * @param rootNode modified data of {@link Neutron} node
      * @return {@link List} of modified subnodes
index 5fe122044fc18d89614a3b91cebcfb4908ba7eb3..09a0efa79ca63030a87c21ab5e75aaa699dacad8 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
 
+import com.google.common.collect.ImmutableList;
+
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
@@ -44,8 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
 
-import com.google.common.collect.ImmutableList;
-
 public class MetadataService extends ServiceUtil {
 
     private static final ClassifierName METADATA_SERVER_TO_CLIENT_NAME =
@@ -57,17 +57,16 @@ public class MetadataService extends ServiceUtil {
         new Description("Allow METADATA management communication between server and client.");
 
     /**
-     * Id of {@link #METADATA_CONTRACT}
+     * Id of {@link #METADATA_CONTRACT}.
      */
     public static final ContractId METADATA_CONTRACT_ID = new ContractId("be0675b7-b0d6-46cc-acf1-247ed31cf572");
     /**
-     * Contains rules with action {@link MappingUtils#ACTION_REF_ALLOW} matching ICMP and SSH
-     * communication
+     * Contains rules with action {@link MappingUtils#ACTION_REF_ALLOW} matching ICMP and SSH communication
      * between Client and Server.
      */
     public static final Contract METADATA_CONTRACT;
     /**
-     * {@link ConsumerNamedSelector} pointing to {@link #METADATA_CONTRACT}
+     * {@link ConsumerNamedSelector} pointing to {@link #METADATA_CONTRACT}.
      */
     public static final ConsumerNamedSelector METADATA_CONTRACT_CONSUMER_SELECTOR;
 
@@ -75,11 +74,11 @@ public class MetadataService extends ServiceUtil {
     private static final Name METADATA_SERVICE_EPG_NAME = new Name("NETWORK_SERVICE");
     private static final Description METADATA_SERVICE_EPG_DESC = new Description("Represents DHCP and DNS servers.");
     /**
-     * ID of {@link #EPG}
+     * ID of {@link #EPG}.
      */
     public static final EndpointGroupId EPG_ID = new EndpointGroupId("ffff1111-dfe5-11e4-8a00-1681e6b88ec1");
     /**
-     * Network-service endpoint-group providing {@link #METADATA_CONTRACT}
+     * Network-service endpoint-group providing {@link #METADATA_CONTRACT}.
      */
     public static final EndpointGroup EPG;
 
@@ -112,37 +111,44 @@ public class MetadataService extends ServiceUtil {
      *
      * @param tenantId location of {@link #METADATA_CONTRACT}
      * @param ipPrefix used in {@link L3EndpointIdentificationConstraints}
-     * @param wTx transaction where entities are written
+     * @param writeTx transaction where entities are written
      */
     public static void writeMetadataClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
-        WriteTransaction wTx) {
+        WriteTransaction writeTx) {
         Clause clause = createClauseWithConsProvEic(ipPrefix, METADATA_SUBJECT_NAME);
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, METADATA_CONTRACT_ID, clause.getName()),
-            clause, true);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, METADATA_CONTRACT_ID,
+            clause.getName()), clause, true);
     }
 
     /**
      * Puts network service entities (classifier-instances, {@link #METADATA_CONTRACT},
-     * and {@link #EPG}) to {@link LogicalDatastoreType#CONFIGURATION}
+     * and {@link #EPG}) to {@link LogicalDatastoreType#CONFIGURATION}.
      *
      * @param tenantId location of network-service entities
-     * @param wTx transaction where network-service entities are written
+     * @param writeTx transaction where network-service entities are written
+     * @param metadataPort port for metadata
      */
-    public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction wTx, long metadataPort) {
+    public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx,
+        long metadataPort) {
+
         Set<ClassifierInstance> classifierInstances = getAllClassifierInstances(metadataPort);
         for (ClassifierInstance ci : classifierInstances) {
-            wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()), ci,
-                    true);
+            writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()),
+                ci, true);
         }
         for (ActionInstance ai : Collections.singleton(MappingUtils.ACTION_ALLOW)) {
-            wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai, true);
-        }
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, METADATA_CONTRACT_ID), METADATA_CONTRACT,
+            writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai,
                 true);
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
+        }
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, METADATA_CONTRACT_ID),
+            METADATA_CONTRACT, true);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
     }
 
     /**
+     * Used to get all classifier-instances used in {@link #METADATA_CONTRACT} for specified port.
+     *
+     * @param metadataPort port for metadata
      * @return All classifier-instances used in {@link #METADATA_CONTRACT}
      */
     public static Set<ClassifierInstance> getAllClassifierInstances(long metadataPort) {
index 75a7907a0155320cdfb876b341c10ecfa0446ef7..d693ec9b3a4f94f8e3d0dd7b0b1c2b0d18a08025 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
 
+import com.google.common.base.Preconditions;
+
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.groupbasedpolicy.util.IidFactory;
@@ -18,18 +20,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerNamedSelector;
 
-import com.google.common.base.Preconditions;
-
 public class NetworkClient extends ServiceUtil {
 
     private static final Name NETWORK_CLIENT_EPG_NAME = new Name("NETWORK_CLIENT");
     private static final Description NETWORK_CLIENT_EPG_DESC = new Description("Represents DHCP and DNS clients.");
     /**
-     * ID of {@link #EPG}
+     * ID of {@link #EPG}.
      */
     public static final EndpointGroupId EPG_ID = new EndpointGroupId("ccc5e444-573c-11e5-885d-feff819cdc9f");
     /**
-     * Network-client endpoint-group consuming no contract
+     * Network-client endpoint-group consuming no contract.
      */
     public static final EndpointGroup EPG;
 
@@ -42,26 +42,26 @@ public class NetworkClient extends ServiceUtil {
     }
 
     /**
-     * Puts {@link #EPG} to {@link LogicalDatastoreType#CONFIGURATION}
+     * Puts {@link #EPG} to {@link LogicalDatastoreType#CONFIGURATION}.
      *
      * @param tenantId location of {@link #EPG}
-     * @param wTx transaction where {@link #EPG} is written
+     * @param writeTx transaction where {@link #EPG} is written
      */
-    public static void writeNetworkClientEntitiesToTenant(TenantId tenantId, WriteTransaction wTx) {
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
+    public static void writeNetworkClientEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx) {
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
     }
 
     /**
-     * Puts consumer-named-selector to {@link #EPG} in {@link LogicalDatastoreType#CONFIGURATION}
+     * Puts consumer-named-selector to {@link #EPG} in {@link LogicalDatastoreType#CONFIGURATION}.
      *
      * @param tenantId tenantId location of {@link #EPG}
      * @param consumerNamedSelector is added to {@link #EPG}
-     * @param wTx transaction where the given consumer-named-selector is written
+     * @param writeTx transaction where the given consumer-named-selector is written
      */
     public static void writeConsumerNamedSelector(TenantId tenantId, ConsumerNamedSelector consumerNamedSelector,
-            WriteTransaction wTx) {
+            WriteTransaction writeTx) {
         Preconditions.checkNotNull(consumerNamedSelector);
-        wTx.put(LogicalDatastoreType.CONFIGURATION,
+        writeTx.put(LogicalDatastoreType.CONFIGURATION,
                 IidFactory.consumerNamedSelectorIid(tenantId, EPG_ID, consumerNamedSelector.getName()),
                 consumerNamedSelector, true);
     }
index 5dad3f0595a70a65e5390efead1d177c038738bc..c62c58334f46aaf8fe89df718713aad22a2006c4 100755 (executable)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
 
+import com.google.common.collect.ImmutableList;
+
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
@@ -44,12 +46,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
 
-import com.google.common.collect.ImmutableList;
-
 public class NetworkService extends ServiceUtil {
 
     /**
-     * Unit tests {@link NetworkServiceTest}
+     * Unit tests {@link NetworkServiceTest}.
      */
     // ########### DHCP
     private static final long DHCP_IPV4_SERVER_PORT = 67;
@@ -69,7 +69,7 @@ public class NetworkService extends ServiceUtil {
             new Description("Allow DHCP communication between client and server.");
 
     /**
-     * Id of {@link #DHCP_CONTRACT}
+     * Id of {@link #DHCP_CONTRACT}.
      */
     public static final ContractId DHCP_CONTRACT_ID = new ContractId("11118d2e-dddd-11e5-885d-feff819cdc9f");
     /**
@@ -78,7 +78,7 @@ public class NetworkService extends ServiceUtil {
      */
     public static final Contract DHCP_CONTRACT;
     /**
-     * {@link ConsumerNamedSelector} pointing to {@link #DHCP_CONTRACT}
+     * {@link ConsumerNamedSelector} pointing to {@link #DHCP_CONTRACT}.
      */
     public static final ConsumerNamedSelector DHCP_CONTRACT_CONSUMER_SELECTOR;
 
@@ -104,7 +104,7 @@ public class NetworkService extends ServiceUtil {
     private static final Description DNS_CONTRACT_DESC =
             new Description("Allow DNS communication between client and server.");
     /**
-     * ID of {@link #DNS_CONTRACT}
+     * ID of {@link #DNS_CONTRACT}.
      */
     public static final ContractId DNS_CONTRACT_ID = new ContractId("22218d2e-dddd-11e5-885d-feff819cdc9f");
     /**
@@ -113,7 +113,7 @@ public class NetworkService extends ServiceUtil {
      */
     public static final Contract DNS_CONTRACT;
     /**
-     * {@link ConsumerNamedSelector} pointing to {@link #DNS_CONTRACT}
+     * {@link ConsumerNamedSelector} pointing to {@link #DNS_CONTRACT}.
      */
     public static final ConsumerNamedSelector DNS_CONTRACT_CONSUMER_SELECTOR;
 
@@ -136,17 +136,16 @@ public class NetworkService extends ServiceUtil {
             new Description("Allow ICMP and SSH management communication between server and client.");
 
     /**
-     * Id of {@link #MGMT_CONTRACT}
+     * Id of {@link #MGMT_CONTRACT}.
      */
     public static final ContractId MGMT_CONTRACT_ID = new ContractId("33318d2e-dddd-11e5-885d-feff819cdc9f");
     /**
-     * Contains rules with action {@link MappingUtils#ACTION_REF_ALLOW} matching ICMP and SSH
-     * communication
+     * Contains rules with action {@link MappingUtils#ACTION_REF_ALLOW} matching ICMP and SSH communication
      * between Client and Server.
      */
     public static final Contract MGMT_CONTRACT;
     /**
-     * {@link ConsumerNamedSelector} pointing to {@link #MGMT_CONTRACT}
+     * {@link ConsumerNamedSelector} pointing to {@link #MGMT_CONTRACT}.
      */
     public static final ConsumerNamedSelector MGMT_CONTRACT_CONSUMER_SELECTOR;
 
@@ -154,11 +153,11 @@ public class NetworkService extends ServiceUtil {
     private static final Name NETWORK_SERVICE_EPG_NAME = new Name("NETWORK_SERVICE");
     private static final Description NETWORK_SERVICE_EPG_DESC = new Description("Represents DHCP and DNS servers.");
     /**
-     * ID of {@link #EPG}
+     * ID of {@link #EPG}.
      */
     public static final EndpointGroupId EPG_ID = new EndpointGroupId("ddd6cfe6-dfe5-11e4-8a00-1681e6b88ec1");
     /**
-     * Network-service endpoint-group providing {@link #DHCP_CONTRACT} and {@link #DNS_CONTRACT}
+     * Network-service endpoint-group providing {@link #DHCP_CONTRACT} and {@link #DNS_CONTRACT}.
      */
     public static final EndpointGroup EPG;
 
@@ -237,13 +236,13 @@ public class NetworkService extends ServiceUtil {
      *
      * @param tenantId location of {@link #DHCP_CONTRACT}
      * @param ipPrefix used in {@link L3EndpointIdentificationConstraints}
-     * @param wTx transaction where entities are written
+     * @param writeTx transaction where entities are written
      */
     public static void writeDhcpClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
-            WriteTransaction wTx) {
+            WriteTransaction writeTx) {
         Clause clause = createClauseWithConsProvEic(ipPrefix, DHCP_SUBJECT_NAME);
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, DHCP_CONTRACT_ID, clause.getName()),
-                clause, true);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, DHCP_CONTRACT_ID,
+            clause.getName()), clause, true);
     }
 
     /**
@@ -252,13 +251,13 @@ public class NetworkService extends ServiceUtil {
      *
      * @param tenantId location of {@link #DNS_CONTRACT}
      * @param ipPrefix used in {@link L3EndpointIdentificationConstraints}
-     * @param wTx transaction where entities are written
+     * @param writeTx transaction where entities are written
      */
     public static void writeDnsClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
-            WriteTransaction wTx) {
+            WriteTransaction writeTx) {
         Clause clause = createClauseWithConsProvEic(ipPrefix, DNS_SUBJECT_NAME);
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, DNS_CONTRACT_ID, clause.getName()),
-                clause, true);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, DNS_CONTRACT_ID,
+            clause.getName()), clause, true);
     }
 
     /**
@@ -267,44 +266,46 @@ public class NetworkService extends ServiceUtil {
      *
      * @param tenantId location of {@link #MGMT_CONTRACT}
      * @param ipPrefix used in {@link L3EndpointIdentificationConstraints}
-     * @param wTx transaction where entities are written
+     * @param writeTx transaction where entities are written
      */
     public static void writeMgmtClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
-            WriteTransaction wTx) {
+            WriteTransaction writeTx) {
         Clause clause = createClauseWithConsProvEic(ipPrefix, MGMT_SUBJECT_NAME);
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, MGMT_CONTRACT_ID, clause.getName()),
-                clause, true);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, MGMT_CONTRACT_ID,
+            clause.getName()), clause, true);
     }
 
     /**
      * Puts network service entities (classifier-instances, {@link #DHCP_CONTRACT},
      * {@link #DNS_CONTRACT}, {@link #MGMT_CONTRACT} and {@link #EPG}) to
-     * {@link LogicalDatastoreType#CONFIGURATION}
+     * {@link LogicalDatastoreType#CONFIGURATION}.
      *
      * @param tenantId location of network-service entities
-     * @param wTx transaction where network-service entities are written
+     * @param writeTx transaction where network-service entities are written
      */
-    public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction wTx) {
+    public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx) {
         Set<ClassifierInstance> classifierInstances = getAllClassifierInstances();
         for (ClassifierInstance ci : classifierInstances) {
-            wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()), ci,
-                    true);
+            writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()),
+                ci, true);
         }
         for (ActionInstance ai : Collections.singleton(MappingUtils.ACTION_ALLOW)) {
-            wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai, true);
-        }
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DHCP_CONTRACT_ID), DHCP_CONTRACT,
-                true);
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DNS_CONTRACT_ID), DNS_CONTRACT,
+            writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai,
                 true);
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, MGMT_CONTRACT_ID), MGMT_CONTRACT,
-                true);
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
+        }
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DHCP_CONTRACT_ID),
+            DHCP_CONTRACT, true);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DNS_CONTRACT_ID), DNS_CONTRACT,
+            true);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, MGMT_CONTRACT_ID),
+            MGMT_CONTRACT, true);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
     }
 
     /**
+     * Used to get all Classifier instances.
      * @return All classifier-instances used in {@link #DHCP_CONTRACT}, {@link #DNS_CONTRACT} and
-     *         {@link #MGMT_CONTRACT}
+     * {@link #MGMT_CONTRACT}.
      */
     public static Set<ClassifierInstance> getAllClassifierInstances() {
         HashSet<ClassifierInstance> cis = new HashSet<>();
index db66f120f7f1fb1703442852614f104fb899b02e..31c6c5423e563d99e3fed61f0f1054020196efd9 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
 
+import com.google.common.collect.ImmutableList;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -41,8 +43,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValueBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.Contract;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.ContractBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroup.IntraGroupPolicy;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Clause;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.ClauseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Subject;
@@ -59,8 +61,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstanceBuilder;
 
-import com.google.common.collect.ImmutableList;
-
 public class ServiceUtil {
 
     protected static Contract createContract(ContractId cid, List<Subject> subjects, Description description) {
@@ -68,7 +68,7 @@ public class ServiceUtil {
     }
 
     protected static ClassifierInstance createClassifInstance(ClassifierName name, ClassifierDefinitionId id,
-            List<ParameterValue> pv) {
+        List<ParameterValue> pv) {
         return new ClassifierInstanceBuilder().setName(name)
             .setClassifierDefinitionId(id)
             .setParameterValue(pv)
@@ -83,7 +83,7 @@ public class ServiceUtil {
     }
 
     protected static List<ParameterValue> createParams(long etherType, long proto, @Nullable Long srcPort,
-            @Nullable Long dstPort) {
+        @Nullable Long dstPort) {
         List<ParameterValue> params = new ArrayList<>();
         if (srcPort != null) {
             params.add(new ParameterValueBuilder().setName(new ParameterName(L4ClassifierDefinition.SRC_PORT_PARAM))
@@ -105,62 +105,54 @@ public class ServiceUtil {
     }
 
     protected static Clause createClauseWithConsProvEic(@Nullable IpPrefix ipPrefix, SubjectName subjectName) {
-         ConsumerMatchers consumerMatchers = null;
-         ProviderMatchers providerMatchers = null;
-         StringBuilder clauseName = new StringBuilder();
-         clauseName.append(subjectName.getValue());
-         if (ipPrefix != null) {
-             clauseName.append(MappingUtils.NAME_DOUBLE_DELIMETER).append(Utils.getStringIpPrefix(ipPrefix));
-             consumerMatchers =
-                     new ConsumerMatchersBuilder()
-                         .setEndpointIdentificationConstraints(new EndpointIdentificationConstraintsBuilder()
-                             .setL3EndpointIdentificationConstraints(new L3EndpointIdentificationConstraintsBuilder()
-                                 .setPrefixConstraint(
-                                         ImmutableList.of(new PrefixConstraintBuilder().setIpPrefix(ipPrefix).build()))
-                                 .build())
-                             .build())
-                         .build();
-             providerMatchers =
-                     new ProviderMatchersBuilder()
-                         .setEndpointIdentificationConstraints(new EndpointIdentificationConstraintsBuilder()
-                             .setL3EndpointIdentificationConstraints(new L3EndpointIdentificationConstraintsBuilder()
-                                 .setPrefixConstraint(
-                                         ImmutableList.of(new PrefixConstraintBuilder().setIpPrefix(ipPrefix).build()))
-                                 .build())
-                             .build())
-                         .build();
-         }
-         return new ClauseBuilder().setName(new ClauseName(clauseName.toString()))
-             .setSubjectRefs(ImmutableList.of(subjectName))
-             .setConsumerMatchers(consumerMatchers)
-             .setProviderMatchers(providerMatchers)
-             .build();
-     }
+        ConsumerMatchers consumerMatchers = null;
+        ProviderMatchers providerMatchers = null;
+        StringBuilder clauseName = new StringBuilder();
+        clauseName.append(subjectName.getValue());
+        if (ipPrefix != null) {
+            clauseName.append(MappingUtils.NAME_DOUBLE_DELIMETER).append(Utils.getStringIpPrefix(ipPrefix));
+            consumerMatchers =
+                new ConsumerMatchersBuilder().setEndpointIdentificationConstraints(
+                    new EndpointIdentificationConstraintsBuilder().setL3EndpointIdentificationConstraints(
+                        new L3EndpointIdentificationConstraintsBuilder().setPrefixConstraint(
+                            ImmutableList.of(new PrefixConstraintBuilder().setIpPrefix(ipPrefix).build())).build())
+                        .build()).build();
+            providerMatchers =
+                new ProviderMatchersBuilder().setEndpointIdentificationConstraints(
+                    new EndpointIdentificationConstraintsBuilder().setL3EndpointIdentificationConstraints(
+                        new L3EndpointIdentificationConstraintsBuilder().setPrefixConstraint(
+                            ImmutableList.of(new PrefixConstraintBuilder().setIpPrefix(ipPrefix).build())).build())
+                        .build()).build();
+        }
+        return new ClauseBuilder().setName(new ClauseName(clauseName.toString()))
+            .setSubjectRefs(ImmutableList.of(subjectName))
+            .setConsumerMatchers(consumerMatchers)
+            .setProviderMatchers(providerMatchers)
+            .build();
+    }
 
     protected static Rule createRuleAllow(ClassifierName classifierName, Direction direction) {
-         ClassifierName name =
-                 new ClassifierName(direction.name() + MappingUtils.NAME_DOUBLE_DELIMETER + classifierName.getValue());
-         ClassifierRef classifierRef = new ClassifierRefBuilder().setName(name)
-             .setInstanceName(classifierName)
-             .setDirection(direction)
-             .build();
-         return new RuleBuilder().setName(new RuleName(name))
-             .setActionRef(ImmutableList.<ActionRef>of(MappingUtils.ACTION_REF_ALLOW))
-             .setClassifierRef(ImmutableList.of(classifierRef))
-             .build();
-     }
+        ClassifierName name =
+            new ClassifierName(direction.name() + MappingUtils.NAME_DOUBLE_DELIMETER + classifierName.getValue());
+        ClassifierRef classifierRef =
+            new ClassifierRefBuilder().setName(name).setInstanceName(classifierName).setDirection(direction).build();
+        return new RuleBuilder().setName(new RuleName(name))
+            .setActionRef(ImmutableList.<ActionRef>of(MappingUtils.ACTION_REF_ALLOW))
+            .setClassifierRef(ImmutableList.of(classifierRef))
+            .build();
+    }
 
     protected static ProviderNamedSelector createProviderSelector(Contract contract) {
-         SelectorName selectorName = new SelectorName(contract.getSubject().get(0).getName().getValue());
-         return new ProviderNamedSelectorBuilder().setName(selectorName)
-             .setContract(ImmutableList.of(contract.getId()))
-             .build();
-     }
+        SelectorName selectorName = new SelectorName(contract.getSubject().get(0).getName().getValue());
+        return new ProviderNamedSelectorBuilder().setName(selectorName)
+            .setContract(ImmutableList.of(contract.getId()))
+            .build();
+    }
 
     protected static ConsumerNamedSelector createConsumerSelector(Contract contract) {
-         SelectorName selectorName = new SelectorName(contract.getSubject().get(0).getName().getValue());
-         return new ConsumerNamedSelectorBuilder().setName(selectorName)
-             .setContract(ImmutableList.of(contract.getId()))
-             .build();
-     }
+        SelectorName selectorName = new SelectorName(contract.getSubject().get(0).getName().getValue());
+        return new ConsumerNamedSelectorBuilder().setName(selectorName)
+            .setContract(ImmutableList.of(contract.getId()))
+            .build();
+    }
 }
index 9bc876f9d78d213958122aa6d41dd040157e59c1..605fd0a7b2d96252b5ee591ab8bf804376c1ab1d 100644 (file)
@@ -14,7 +14,8 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 public interface NeutronAware<T extends DataObject> {
 
     void onCreated(T createdItem, Neutron neutron);
+
     void onUpdated(T oldItem, T newItem, Neutron oldNeutron, Neutron newNeutron);
-    void onDeleted(T deletedItem, Neutron oldNeutron, Neutron newNeutron);
 
+    void onDeleted(T deletedItem, Neutron oldNeutron, Neutron newNeutron);
 }
index 2c7b97af2690dab823e0c94d9c6c867e12e43600..6b6ff535a5990f88ca4281ad02df252f9097e2ec 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.base.Objects;
+
 import java.util.concurrent.ExecutionException;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -19,10 +21,7 @@ import org.opendaylight.groupbasedpolicy.neutron.mapper.util.Utils;
 import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
 import org.opendaylight.groupbasedpolicy.util.IidFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpointKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev170511.IpPrefixType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev170511.L3Context;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.l3endpoint.rev151217.NatAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.l3endpoint.rev151217.NatAddressBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.floatingips.attributes.Floatingips;
@@ -33,8 +32,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Objects;
-
 public class NeutronFloatingIpAware implements NeutronAware<Floatingip> {
 
     private static final Logger LOG = LoggerFactory.getLogger(NeutronFloatingIpAware.class);
index 00342dcb2d82a5084ae249d1070ad59ae811c654..f5bba0e22828c4a54f039923bb15caf1d79a0bc6 100644 (file)
@@ -9,6 +9,9 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+
 import java.util.HashSet;
 import java.util.Set;
 
@@ -48,9 +51,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
 public class NeutronNetworkAware implements NeutronAware<Network> {
 
     private static final Logger LOG = LoggerFactory.getLogger(NeutronNetworkAware.class);
@@ -68,18 +68,16 @@ public class NeutronNetworkAware implements NeutronAware<Network> {
     @Override
     public void onCreated(Network network, Neutron neutron) {
         LOG.trace("created network - {}", network);
-        ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
-        TenantId tenantId = new TenantId(network.getTenantId().getValue());
         Name name;
         ContextId ctxId = new ContextId(network.getUuid().getValue());
         ForwardingContextBuilder fwdCtxBuilder = new ForwardingContextBuilder()
-        .setContextId(ctxId)
-        .setContextType(MappingUtils.L3_CONTEXT);
+            .setContextId(ctxId)
+            .setContextType(MappingUtils.L3_CONTEXT);
         if (!Strings.isNullOrEmpty(network.getName())) {
             try {
                 name = new Name(network.getName());
                 fwdCtxBuilder.setName(name);
-            } catch (Exception e) {
+            } catch (NullPointerException | IllegalArgumentException e) {
                 LOG.info("Name of Neutron Network '{}' is ignored.", network.getName());
                 LOG.debug("Name exception", e);
             }
@@ -88,14 +86,15 @@ public class NeutronNetworkAware implements NeutronAware<Network> {
         ForwardingContext l3Context = fwdCtxBuilder.build();
 
         fwdCtxBuilder.setContextType(MappingUtils.L2_BRDIGE_DOMAIN)
-
-        .setParent(MappingUtils.createParent(ctxId, MappingUtils.L3_CONTEXT));
+            .setParent(MappingUtils.createParent(ctxId, MappingUtils.L3_CONTEXT));
         ForwardingContext l2Bd = fwdCtxBuilder.build();
 
-        fwdCtxBuilder.setContextType(MappingUtils.L2_FLOOD_DOMAIN).setParent(
-                MappingUtils.createParent(ctxId, MappingUtils.L2_BRDIGE_DOMAIN));
+        fwdCtxBuilder.setContextType(MappingUtils.L2_FLOOD_DOMAIN)
+            .setParent(MappingUtils.createParent(ctxId, MappingUtils.L2_BRDIGE_DOMAIN));
         ForwardingContext l2Fd = fwdCtxBuilder.build();
 
+        ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
+        TenantId tenantId = new TenantId(network.getTenantId().getValue());
         rwTx.put(LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.l3ContextIid(tenantId, ctxId), l3Context, true);
         rwTx.put(LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.l2BridgeDomainIid(tenantId, ctxId), l2Bd, true);
         rwTx.put(LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.l2FloodDomainIid(tenantId, ctxId), l2Fd, true);
@@ -140,8 +139,7 @@ public class NeutronNetworkAware implements NeutronAware<Network> {
                 l3CtxBuilder.setName(name);
                 l2FdBuilder.setName(name);
                 l2BdBuilder.setName(name);
-            } catch (Exception e) {
-                name = null;
+            } catch (NullPointerException | IllegalArgumentException e) {
                 LOG.info("Name of Neutron Network '{}' is ignored.", network.getName());
                 LOG.debug("Name exception", e);
             }
@@ -149,7 +147,8 @@ public class NeutronNetworkAware implements NeutronAware<Network> {
         L2FloodDomainId l2FdId = new L2FloodDomainId(network.getUuid().getValue());
         L3ContextId l3ContextId = new L3ContextId(l2FdId);
         L3Context l3Context = l3CtxBuilder.setId(l3ContextId).build();
-        rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3Context.getId()), l3Context, true);
+        rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3Context.getId()), l3Context,
+            true);
 
         L2BridgeDomainId l2BdId = new L2BridgeDomainId(l2FdId);
         L2BridgeDomain l2Bd = l2BdBuilder.setId(l2BdId).setParent(l3Context.getId()).build();
@@ -160,25 +159,27 @@ public class NeutronNetworkAware implements NeutronAware<Network> {
     }
 
     private void addProviderPhysicalNetworkMapping(TenantId tenantId, ContextId ctxId, String segmentationId,
-            WriteTransaction wTx) {
-        ProviderPhysicalNetworkAsL2FloodDomain provNetAsL2Fd = new ProviderPhysicalNetworkAsL2FloodDomainBuilder().setTenantId(
-                tenantId)
+            WriteTransaction writeTx) {
+        ProviderPhysicalNetworkAsL2FloodDomain provNetAsL2Fd =
+            new ProviderPhysicalNetworkAsL2FloodDomainBuilder().setTenantId(tenantId)
             .setL2FloodDomainId(ctxId)
             .setSegmentationId(segmentationId)
             .build();
-        wTx.put(LogicalDatastoreType.OPERATIONAL,
+        writeTx.put(LogicalDatastoreType.OPERATIONAL,
                 NeutronGbpIidFactory.providerPhysicalNetworkAsL2FloodDomainIid(tenantId, ctxId), provNetAsL2Fd);
     }
 
     @Deprecated
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private void addProviderPhysicalNetworkMapping(TenantId tenantId, L2FloodDomainId l2FdId, String segmentationId,
-            WriteTransaction wTx) {
+            WriteTransaction writeTx) {
         org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.provider.physical.networks.as.l2.flood.domains.ProviderPhysicalNetworkAsL2FloodDomain provNetAsL2Fd = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.provider.physical.networks.as.l2.flood.domains.ProviderPhysicalNetworkAsL2FloodDomainBuilder().setTenantId(
                 tenantId)
             .setL2FloodDomainId(new L2FloodDomainId(l2FdId.getValue()))
             .setSegmentationId(segmentationId)
             .build();
-        wTx.put(LogicalDatastoreType.OPERATIONAL,
+        writeTx.put(LogicalDatastoreType.OPERATIONAL,
                 NeutronGbpIidFactory.providerPhysicalNetworkAsL2FloodDomainIid(tenantId, l2FdId), provNetAsL2Fd);
     }
 
index 951d593855cb71a5ea6100032871f10f74492419..6eed62dbb9a69543c19ac78bc1597b6d7b6889aa 100644 (file)
@@ -9,11 +9,14 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
-import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
 
 import javax.annotation.Nullable;
@@ -94,10 +97,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
 public class NeutronPortAware implements NeutronAware<Port> {
 
     private static final Logger LOG = LoggerFactory.getLogger(NeutronPortAware.class);
@@ -119,6 +118,8 @@ public class NeutronPortAware implements NeutronAware<Port> {
         onCreated(createdItem, neutron, true);
     }
 
+    @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 onCreated(Port port, Neutron neutron, boolean addBaseEpMapping) {
         LOG.trace("created port - {}", port);
         if (PortUtils.isRouterInterfacePort(port)) {
@@ -129,12 +130,12 @@ public class NeutronPortAware implements NeutronAware<Port> {
                 LOG.warn("Illegal state - router interface port does not contain fixed IPs {}", port);
                 return;
             }
-            FixedIps portIpWithSubnet = potentialPortIpWithSubnet.get();
-            ContextId routerL3Context = new ContextId(port.getDeviceId());
-            ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
+            final FixedIps portIpWithSubnet = potentialPortIpWithSubnet.get();
+            final ContextId routerL3Context = new ContextId(port.getDeviceId());
             AddressEndpointKey addrEpKey = new AddressEndpointKey(port.getMacAddress().getValue(), MacAddressType.class,
                     new ContextId(port.getNetworkId().getValue()), MappingUtils.L2_BRDIGE_DOMAIN);
             UniqueId portId = new UniqueId(port.getUuid().getValue());
+            ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
             addBaseEndpointMappings(addrEpKey, portId, rwTx);
             // Add Qrouter and VPProuter port as Endpoint
             if (port.getAugmentation(PortBindingExtension.class) != null && PortUtils.DEVICE_VIF_TYPE
@@ -299,6 +300,8 @@ public class NeutronPortAware implements NeutronAware<Port> {
     }
 
     @Deprecated
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private void processTenantForwarding(Subnet routerPortSubnet, ContextId routerL3Context, FixedIps portIpWithSubnet,
             TenantId tenantId, ReadWriteTransaction rwTx) {
         L2BridgeDomainId l2BdId = new L2BridgeDomainId(routerPortSubnet.getNetworkId().getValue());
@@ -317,6 +320,8 @@ public class NeutronPortAware implements NeutronAware<Port> {
      * Creates registration input for L3 endpoint if fixedIps argument is not null.
      */
     @Deprecated
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder createEndpointRegFromPort(
             Port port, FixedIps fixedIps, NetworkDomainId networkContainment, List<EndpointGroupId> endpointGroupIds,
             Neutron neutron) {
@@ -426,6 +431,8 @@ public class NeutronPortAware implements NeutronAware<Port> {
     }
 
     @Deprecated
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private void modifyL3ContextForEndpoints(Port port, FixedIps resolvedPortFixedIp, ContextId newContextId) {
         org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder epInBuilder =
                 createBasicEndpointInputBuilder(port);
@@ -511,6 +518,8 @@ public class NeutronPortAware implements NeutronAware<Port> {
     }
 
     @Deprecated
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private static org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder createBasicEndpointInputBuilder(
             Port port) {
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder()
@@ -532,6 +541,8 @@ public class NeutronPortAware implements NeutronAware<Port> {
     }
 
     @Deprecated
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private void registerEndpointAndStoreMapping(
             org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput regEpInput,
             Port port, ReadWriteTransaction rwTx) {
@@ -555,6 +566,8 @@ public class NeutronPortAware implements NeutronAware<Port> {
     }
 
     @Deprecated
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private void unregisterEndpointAndRemoveMapping(
             org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput unregEpInput,
             Port port, ReadWriteTransaction rwTx) {
@@ -572,8 +585,23 @@ public class NeutronPortAware implements NeutronAware<Port> {
         }
     }
 
+    private void unregisterEndpointAndRemoveMapping(UnregisterEndpointInput baseEpUnreg, Port port,
+        ReadWriteTransaction rwTx, boolean removeBaseEpMappings) {
+        boolean isUnregisteredBaseEndpoint = epRegistrator.unregisterEndpoint(baseEpUnreg);
+        if (isUnregisteredBaseEndpoint) {
+            UniqueId portId = new UniqueId(port.getUuid().getValue());
+            PortByBaseEndpointKey portByBaseEndpointKey = new PortByBaseEndpointKey(port.getMacAddress().getValue(),
+                MacAddressType.class, new ContextId(port.getNetworkId().getValue()), MappingUtils.L2_BRDIGE_DOMAIN);
+            LOG.trace("Removing Port-BaseEndpoint mapping for port {} (device owner {}) and endpoint {}",
+                port.getUuid().getValue(), port.getDeviceOwner(), portByBaseEndpointKey);
+            if (removeBaseEpMappings) {
+                removeBaseEndpointMappings(portByBaseEndpointKey, portId, rwTx);
+            }
+        }
+    }
+
     private void registerBaseEndpointAndStoreMapping(List<AddressEndpointReg> addrEpRegs, Port port,
-            WriteTransaction wTx, boolean addBaseEpMappings) {
+            WriteTransaction writeTx, boolean addBaseEpMappings) {
         RegisterEndpointInput regBaseEpInput =
                 new RegisterEndpointInputBuilder().setAddressEndpointReg(addrEpRegs).build();
 
@@ -589,36 +617,21 @@ public class NeutronPortAware implements NeutronAware<Port> {
                         port.getUuid());
                 AddressEndpointKey addrEpKey = new AddressEndpointKey(addrEpReg.getAddress(),
                         addrEpReg.getAddressType(), addrEpReg.getContextId(), addrEpReg.getContextType());
-                addBaseEndpointMappings(addrEpKey, portId, wTx);
+                addBaseEndpointMappings(addrEpKey, portId, writeTx);
             }
         }
     }
 
-    private void addBaseEndpointMappings(AddressEndpointKey addrEpKey, UniqueId portId, WriteTransaction wTx) {
+    private void addBaseEndpointMappings(AddressEndpointKey addrEpKey, UniqueId portId, WriteTransaction writeTx) {
         BaseEndpointByPort baseEndpointByPort = MappingFactory.createBaseEndpointByPort(addrEpKey, portId);
-        wTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.baseEndpointByPortIid(portId),
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.baseEndpointByPortIid(portId),
                 baseEndpointByPort, true);
         PortByBaseEndpoint portByBaseEndpoint = MappingFactory.createPortByBaseEndpoint(portId, addrEpKey);
-        wTx.put(LogicalDatastoreType.OPERATIONAL,
+        writeTx.put(LogicalDatastoreType.OPERATIONAL,
                 NeutronGbpIidFactory.portByBaseEndpointIid(new PortByBaseEndpointKey(portByBaseEndpoint.getKey())),
                 portByBaseEndpoint, true);
     }
 
-    private void unregisterEndpointAndRemoveMapping(UnregisterEndpointInput baseEpUnreg, Port port,
-            ReadWriteTransaction rwTx, boolean removeBaseEpMappings) {
-        boolean isUnregisteredBaseEndpoint = epRegistrator.unregisterEndpoint(baseEpUnreg);
-        if (isUnregisteredBaseEndpoint) {
-            UniqueId portId = new UniqueId(port.getUuid().getValue());
-            PortByBaseEndpointKey portByBaseEndpointKey = new PortByBaseEndpointKey(port.getMacAddress().getValue(),
-                    MacAddressType.class, new ContextId(port.getNetworkId().getValue()), MappingUtils.L2_BRDIGE_DOMAIN);
-            LOG.trace("Removing Port-BaseEndpoint mapping for port {} (device owner {}) and endpoint {}",
-                    port.getUuid().getValue(), port.getDeviceOwner(), portByBaseEndpointKey);
-            if (removeBaseEpMappings) {
-                removeBaseEndpointMappings(portByBaseEndpointKey, portId, rwTx);
-            }
-        }
-    }
-
     private void removeBaseEndpointMappings(PortByBaseEndpointKey portByBaseEndpointKey, UniqueId portId,
             ReadWriteTransaction rwTx) {
         DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL,
@@ -722,6 +735,8 @@ public class NeutronPortAware implements NeutronAware<Port> {
     }
 
     @Deprecated
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private void modifyForwardingOnDelete(Subnet routerPortSubnet, L3ContextId l3contextId, TenantId tenantId,
             ReadWriteTransaction rwTx) {
         L2BridgeDomainId l2BdId = new L2BridgeDomainId(routerPortSubnet.getNetworkId().getValue());
@@ -734,9 +749,10 @@ public class NeutronPortAware implements NeutronAware<Port> {
                 tenantSubnet);
     }
 
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.UnregisterEndpointInput createUnregisterBaseEndpointInput(
             Port port, Neutron neutron) {
-        UnregisterEndpointInputBuilder inputBuilder = new UnregisterEndpointInputBuilder();
         List<AddressEndpointUnreg> list = new ArrayList<>();
         AddressEndpointUnregBuilder addrL2EpUnregBuilder = new AddressEndpointUnregBuilder();
         addrL2EpUnregBuilder.setAddress(port.getMacAddress().getValue())
@@ -755,11 +771,14 @@ public class NeutronPortAware implements NeutronAware<Port> {
                 .setContextType(L3Context.class);
             list.add(addrL3EpUnregBuilder.build());
         }
+        UnregisterEndpointInputBuilder inputBuilder = new UnregisterEndpointInputBuilder();
         inputBuilder.setAddressEndpointUnreg(list);
         return inputBuilder.build();
     }
 
     @Deprecated
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput createUnregisterEndpointInput(
             Port port, Neutron neutron) {
         org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInputBuilder inputBuilder =
index b06a408f801d0d99a8bd6f7d3c3692de5009a823..fc1fb23423438ddc6c552cd9a7a18eb5beed0bb9 100644 (file)
@@ -108,7 +108,7 @@ public class NeutronRouterAware implements NeutronAware<Router> {
             try {
                 routerName = new Name(router.getName());
                 fwdCtxBuilder.setName(routerName);
-            } catch (Exception e) {
+            } catch (NullPointerException | IllegalArgumentException e) {
                 LOG.info("Name '{}' of Neutron Subnet '{}' is ignored.", router.getName(),
                         router.getUuid().getValue());
                 LOG.debug("Name exception", e);
@@ -117,23 +117,27 @@ public class NeutronRouterAware implements NeutronAware<Router> {
         ForwardingContext routerl3Context = fwdCtxBuilder.setContextId(routerl3ContextId)
             .setContextType(MappingUtils.L3_CONTEXT)
             .build();
-        WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
-        wTx.put(LogicalDatastoreType.CONFIGURATION, routerL3CtxIid, routerl3Context, true);
-        createTenantL3Context(new L3ContextId(routerl3ContextId), tenantId, routerName, wTx);
-        DataStoreHelper.submitToDs(wTx);
+        WriteTransaction writeTx = dataProvider.newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, routerL3CtxIid, routerl3Context, true);
+        createTenantL3Context(new L3ContextId(routerl3ContextId), tenantId, routerName, writeTx);
+        DataStoreHelper.submitToDs(writeTx);
     }
 
     @Deprecated
-    private void createTenantL3Context(L3ContextId l3ContextId, TenantId tenantId, Name name, WriteTransaction wTx) {
+    private void createTenantL3Context(L3ContextId l3ContextId, TenantId tenantId, Name name,
+        WriteTransaction writeTx) {
         L3ContextBuilder l3ContextBuilder = new L3ContextBuilder();
         if (name != null) {
             l3ContextBuilder.setName(name);
         }
         L3Context l3Context = l3ContextBuilder.setId(l3ContextId).build();
-        wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3ContextId), l3Context, true);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3ContextId), l3Context,
+            true);
     }
 
     @Override
+    @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 onUpdated(Router oldRouter, Router newRouter, Neutron oldNeutron, Neutron newNeutron) {
         LOG.trace("updated router - OLD: {}\nNEW: {}", oldRouter, newRouter);
 
@@ -204,7 +208,7 @@ public class NeutronRouterAware implements NeutronAware<Router> {
                     L2L3IidFactory.l2BridgeDomainIid(tenantId, l2BdId), rwTx);
             if (!optBd.isPresent()) {
                 LOG.warn(
-                        "Could not read L2-Bridge-Domain {}. Modification of its parent to L3-Context of router {} aborted.",
+                    "Could not read L2BridgeDomain {}. Modification of its parent to L3Context of router {} aborted.",
                         l2BdId, newRouter.getUuid());
                 rwTx.cancel();
                 return;
@@ -249,101 +253,114 @@ public class NeutronRouterAware implements NeutronAware<Router> {
         return epRegistrator.unregisterEndpoint(addrEpBuilder.build());
     }
 
-private NetworkDomain createSubnetWithVirtualRouterIp(IpPrefix gatewayIp, NetworkDomainId subnetId, List<Gateways> gateways) {
-        Subnet subnet = new SubnetBuilder()
-            .setVirtualRouterIp(MappingUtils.ipPrefixToIpAddress(gatewayIp.getValue()))
-            .setGateways(gateways)
-            .build();
+    private NetworkDomain createSubnetWithVirtualRouterIp(IpPrefix gatewayIp, NetworkDomainId subnetId,
+        List<Gateways> gateways) {
+
+        Subnet subnet =
+            new SubnetBuilder().setVirtualRouterIp(MappingUtils.ipPrefixToIpAddress(gatewayIp.getValue()))
+                .setGateways(gateways)
+                .build();
         return new NetworkDomainBuilder().setKey(new NetworkDomainKey(subnetId, MappingUtils.SUBNET))
             .addAugmentation(SubnetAugmentForwarding.class,
-                    new SubnetAugmentForwardingBuilder().setSubnet(subnet).build())
+                new SubnetAugmentForwardingBuilder().setSubnet(subnet).build())
             .build();
     }
 
     @Deprecated
-    private void updateTenantForwarding(Neutron newNeutron, Router oldRouter, Router newRouter, L3ContextId l3ContextId, TenantId tenantId, ReadWriteTransaction rwTx) {
-        InstanceIdentifier<L3Context> l3ContextIid =
-                IidFactory.l3ContextIid(tenantId, l3ContextId);
-         Optional<L3Context> optL3Context = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, rwTx);
-         L3Context l3Context;
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
+    private void updateTenantForwarding(Neutron newNeutron, Router oldRouter, Router newRouter, L3ContextId l3ContextId,
+        TenantId tenantId, ReadWriteTransaction rwTx) {
+
+        InstanceIdentifier<L3Context> l3ContextIid = IidFactory.l3ContextIid(tenantId, l3ContextId);
+        Optional<L3Context> optL3Context = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid,
+            rwTx);
+        L3Context l3Context;
         if (!optL3Context.isPresent()) { // add L3 context if missing
             l3Context = createL3CtxFromRouter(newRouter);
             rwTx.put(LogicalDatastoreType.CONFIGURATION, l3ContextIid, l3Context, true);
         }
 
         if (newRouter.getGatewayPortId() != null && oldRouter.getGatewayPortId() == null) {
-             // external network is attached to router
-             Uuid gatewayPortId = newRouter.getGatewayPortId();
-             Optional<Port> potentialGwPort = PortUtils.findPort(gatewayPortId, newNeutron.getPorts());
-             if (!potentialGwPort.isPresent()) {
-                 LOG.warn("Illegal state - router gateway port {} does not exist for router {}.",
-                         gatewayPortId.getValue(), newRouter);
-                 rwTx.cancel();
-                 return;
-             }
-
-             Port gwPort = potentialGwPort.get();
-             List<FixedIps> fixedIpsFromGwPort = gwPort.getFixedIps();
-             if (fixedIpsFromGwPort == null || fixedIpsFromGwPort.isEmpty()) {
-                 LOG.warn("Illegal state - router gateway port {} does not contain fixed IPs {}",
-                         gatewayPortId.getValue(), gwPort);
-                 rwTx.cancel();
-                 return;
-             }
-
-             // router can have only one external network
-             FixedIps ipWithSubnetFromGwPort = fixedIpsFromGwPort.get(0);
-             Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet> potentialSubnet = SubnetUtils.findSubnet(ipWithSubnetFromGwPort.getSubnetId(), newNeutron.getSubnets());
-             if (!potentialSubnet.isPresent()) {
-                 LOG.warn("Illegal state - Subnet {} does not exist for router {}.",
-                         ipWithSubnetFromGwPort.getSubnetId(), newRouter);
-                 rwTx.cancel();
-                 return;
-             }
-             IpAddress gatewayIp =  potentialSubnet.get().getGatewayIp();
-             NetworkDomainId networkContainment = new NetworkDomainId(ipWithSubnetFromGwPort.getSubnetId().getValue());
-             boolean registeredExternalGateway = epRegistrator.registerL3EpAsExternalGateway(tenantId, gatewayIp,
-                     l3ContextId, networkContainment);
-             if (!registeredExternalGateway) {
-                 LOG.warn("Could not add L3Prefix as gateway of default route. Gateway port {}", gwPort);
-                 rwTx.cancel();
-                 return;
-             }
-             EndpointL3Key epL3Key = new EndpointL3Key(gatewayIp, l3ContextId);
-             addNeutronExtGwMapping(epL3Key, rwTx);
-
-             boolean registeredDefaultRoute = epRegistrator.registerExternalL3PrefixEndpoint(MappingUtils.DEFAULT_ROUTE,
-                     l3ContextId, gatewayIp, tenantId);
-             if (!registeredDefaultRoute) {
-                 LOG.warn("Could not add EndpointL3Prefix as default route. Gateway port {}", gwPort);
-                 rwTx.cancel();
-                 return;
-             }
-             org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.Subnet subnetWithGw =
-                     new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetBuilder().setId(new SubnetId(ipWithSubnetFromGwPort.getSubnetId().getValue()))
-                         .setVirtualRouterIp(gatewayIp)
-                 .build();
-             rwTx.merge(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(tenantId, subnetWithGw.getId()),
-                     subnetWithGw);
-             L2BridgeDomainId l2BdId = new L2BridgeDomainId(potentialSubnet.get().getNetworkId().getValue());
-             Optional<L2BridgeDomain> optBd = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,
-                     IidFactory.l2BridgeDomainIid(tenantId, l2BdId), rwTx);
-             if (!optBd.isPresent()) {
-                 LOG.warn(
-                         "Could not read L2-Bridge-Domain {}. Modification of its parent to L3-Context of router {} aborted.",
-                         l2BdId, newRouter.getUuid());
-                 rwTx.cancel();
-                 return;
-             }
-             L2BridgeDomain l2BdWithGw = new L2BridgeDomainBuilder(optBd.get())
-                 .setParent(new L3ContextId(l3ContextId.getValue()))
-                 .build();
-             rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId, l2BdId),
-                     l2BdWithGw);
-         }
+            // external network is attached to router
+            Uuid gatewayPortId = newRouter.getGatewayPortId();
+            Optional<Port> potentialGwPort = PortUtils.findPort(gatewayPortId, newNeutron.getPorts());
+            if (!potentialGwPort.isPresent()) {
+                LOG.warn("Illegal state - router gateway port {} does not exist for router {}.",
+                     gatewayPortId.getValue(), newRouter);
+                rwTx.cancel();
+                return;
+            }
+
+            Port gwPort = potentialGwPort.get();
+            List<FixedIps> fixedIpsFromGwPort = gwPort.getFixedIps();
+            if (fixedIpsFromGwPort == null || fixedIpsFromGwPort.isEmpty()) {
+                LOG.warn("Illegal state - router gateway port {} does not contain fixed IPs {}",
+                     gatewayPortId.getValue(), gwPort);
+                rwTx.cancel();
+                return;
+            }
+
+            // router can have only one external network
+            FixedIps ipWithSubnetFromGwPort = fixedIpsFromGwPort.get(0);
+            Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet>
+                potentialSubnet = SubnetUtils.findSubnet(ipWithSubnetFromGwPort.getSubnetId(), newNeutron.getSubnets());
+            if (!potentialSubnet.isPresent()) {
+                LOG.warn("Illegal state - Subnet {} does not exist for router {}.",
+                    ipWithSubnetFromGwPort.getSubnetId(), newRouter);
+                rwTx.cancel();
+                return;
+            }
+            IpAddress gatewayIp = potentialSubnet.get().getGatewayIp();
+            NetworkDomainId networkContainment = new NetworkDomainId(ipWithSubnetFromGwPort.getSubnetId().getValue());
+            boolean registeredExternalGateway =
+                epRegistrator.registerL3EpAsExternalGateway(tenantId, gatewayIp, l3ContextId, networkContainment);
+            if (!registeredExternalGateway) {
+                LOG.warn("Could not add L3Prefix as gateway of default route. Gateway port {}", gwPort);
+                rwTx.cancel();
+                return;
+            }
+            EndpointL3Key epL3Key = new EndpointL3Key(gatewayIp, l3ContextId);
+            addNeutronExtGwMapping(epL3Key, rwTx);
+
+            boolean registeredDefaultRoute = epRegistrator.registerExternalL3PrefixEndpoint(MappingUtils.DEFAULT_ROUTE,
+                l3ContextId, gatewayIp, tenantId);
+            if (!registeredDefaultRoute) {
+                LOG.warn("Could not add EndpointL3Prefix as default route. Gateway port {}", gwPort);
+                rwTx.cancel();
+                return;
+            }
+            org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.Subnet
+                subnetWithGw =
+                new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetBuilder()
+                    .setId(new SubnetId(ipWithSubnetFromGwPort.getSubnetId().getValue()))
+                    .setVirtualRouterIp(gatewayIp)
+                    .build();
+            rwTx.merge(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(tenantId, subnetWithGw.getId()),
+                subnetWithGw);
+            L2BridgeDomainId l2BdId = new L2BridgeDomainId(potentialSubnet.get().getNetworkId().getValue());
+            Optional<L2BridgeDomain> optBd =
+                DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId,
+                    l2BdId), rwTx);
+            if (!optBd.isPresent()) {
+                LOG.warn(
+                    "Could not read L2BridgeDomain {}. Modification of its parent to L3Context of router {} aborted.",
+                    l2BdId, newRouter.getUuid());
+                rwTx.cancel();
+                return;
+            }
+            L2BridgeDomain
+                l2BdWithGw =
+                new L2BridgeDomainBuilder(optBd.get()).setParent(new L3ContextId(l3ContextId.getValue())).build();
+            rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId, l2BdId), l2BdWithGw);
+        }
     }
 
-    private void deleteTenantForwarding(Neutron newNeutron, Router oldRouter, L3ContextId l3ContextId, TenantId tenantId, ReadWriteTransaction rwTx) {
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
+    private void deleteTenantForwarding(Neutron newNeutron, Router oldRouter, L3ContextId l3ContextId,
+        TenantId tenantId, ReadWriteTransaction rwTx) {
+
         InstanceIdentifier<L3Context> l3ContextIid = IidFactory.l3ContextIid(tenantId, l3ContextId);
 
         LOG.trace("Deleting router from TenantForwarding {}", l3ContextIid);
@@ -408,9 +425,9 @@ private NetworkDomain createSubnetWithVirtualRouterIp(IpPrefix gatewayIp, Networ
                 IidFactory.subnetIid(tenantId, new SubnetId(ipWithSubnetFromGwPort.getSubnetId().getValue())), subnet);
 
             L2BridgeDomainId l2BdId = new L2BridgeDomainId(potentialSubnet.get().getNetworkId().getValue());
-            L3ContextId l3Context = new L3ContextId( potentialSubnet.get().getNetworkId().getValue());
+            L3ContextId l3Context = new L3ContextId(potentialSubnet.get().getNetworkId().getValue());
             Optional<L2BridgeDomain> optBd = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,
-                IidFactory.l2BridgeDomainIid(tenantId, l2BdId), rwTx);
+                    IidFactory.l2BridgeDomainIid(tenantId, l2BdId), rwTx);
             if (optBd.isPresent()) {
                 L2BridgeDomain l2BdWithGw = new L2BridgeDomainBuilder(optBd.get()).setParent(l3Context).build();
                 LOG.trace("Setting parent for L2BridgeDomain {} back to network {}.", l2BdWithGw, l3Context);
@@ -447,8 +464,8 @@ private NetworkDomain createSubnetWithVirtualRouterIp(IpPrefix gatewayIp, Networ
     private static void addNeutronExtGwGbpMapping(ContextId contextId, IpPrefix ipPrefix, ReadWriteTransaction rwTx) {
         ExternalGatewayAsEndpoint externalGatewayL3Endpoint = MappingFactory.createEaxternalGatewayAsEndpoint(
                 contextId, ipPrefix);
-        rwTx.put(LogicalDatastoreType.OPERATIONAL,
-                NeutronGbpIidFactory.externalGatewayAsEndpoint(contextId, ipPrefix, MappingUtils.L3_CONTEXT), externalGatewayL3Endpoint, true);
+        rwTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.externalGatewayAsEndpoint(contextId,
+            ipPrefix, MappingUtils.L3_CONTEXT), externalGatewayL3Endpoint, true);
     }
 
     @Deprecated
@@ -481,6 +498,8 @@ private NetworkDomain createSubnetWithVirtualRouterIp(IpPrefix gatewayIp, Networ
         DataStoreHelper.submitToDs(rwTx);
     }
 
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     private void deleteExtGw(Router router, TenantId tenantId, Neutron newNeutron, ReadWriteTransaction rwTx) {
         ContextId routerL3CtxId = new ContextId(router.getUuid().getValue());
         if (router.getGatewayPortId() != null) {
index 90ecae6185b256f8ad1444b1ab96f22b22a9dd70..3ec4c43b2b34f03b41950180e40be469f56663d8 100644 (file)
@@ -9,6 +9,9 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -31,9 +34,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
 public class NeutronSecurityGroupAware implements NeutronAware<SecurityGroup> {
 
     private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityGroupAware.class);
@@ -66,24 +66,25 @@ public class NeutronSecurityGroupAware implements NeutronAware<SecurityGroup> {
             // TODO This needs to be reworked, SecGroups shouldn't use TenantId, Neutron doesn't always configure it
             return true;
         }
-        TenantId tId = new TenantId(secGroup.getTenantId().getValue());
+        TenantId tenantId = new TenantId(secGroup.getTenantId().getValue());
         EndpointGroupId epgId = new EndpointGroupId(secGroup.getUuid().getValue());
         if (epgId.getValue().equals(MappingUtils.EIG_UUID.getValue())) {
             ExternalImplicitGroup eig = new ExternalImplicitGroupBuilder().setId(epgId).build();
-            rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.externalImplicitGroupIid(tId, epgId), eig, true);
+            rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.externalImplicitGroupIid(tenantId, epgId), eig,
+                true);
         }
         EndpointGroupBuilder epgBuilder = new EndpointGroupBuilder().setId(epgId);
         if (!Strings.isNullOrEmpty(secGroup.getName())) {
             try {
                 epgBuilder.setName(new Name(secGroup.getName()));
-            } catch (Exception e) {
+            } catch (NullPointerException | IllegalArgumentException e) {
                 LOG.info("Name '{}' of Neutron Security-group '{}' is ignored.", secGroup.getName(),
                         secGroup.getUuid().getValue());
                 LOG.debug("Name exception", e);
             }
         }
         epgBuilder.setIntraGroupPolicy(IntraGroupPolicy.RequireContract);
-        rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tId, epgId),
+        rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, epgId),
                 epgBuilder.build(), true);
         return true;
     }
index db22e962f923a6fc956c5c76c2fac8454ac1a7bc..0c2c7a85e7a32a835a94c0ab3674b4c8284f555f 100644 (file)
@@ -9,6 +9,9 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+
 import java.util.Collections;
 import java.util.List;
 import java.util.function.Function;
@@ -51,13 +54,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
+@SuppressWarnings("checkstyle:LineLength") // Longer lines in this class are caused by long package names,
+                                           // this will be removed when deprecated classes will be cleared.
 public class NeutronSubnetAware implements
         NeutronAware<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet> {
 
-    private final static Logger LOG = LoggerFactory.getLogger(NeutronSubnetAware.class);
+    private static final Logger LOG = LoggerFactory.getLogger(NeutronSubnetAware.class);
     public static final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet> SUBNET_WILDCARD_IID =
             InstanceIdentifier.builder(Neutron.class)
                 .child(Subnets.class)
@@ -148,7 +150,8 @@ public class NeutronSubnetAware implements
                     .stream()
                     .filter(net -> net.getUuid().equals(port.getNetworkId()))
                     .filter(net -> net.getAugmentation(NetworkProviderExtension.class) != null)
-                    .anyMatch(net -> net.getAugmentation(NetworkProviderExtension.class).getPhysicalNetwork() != null)) {
+                    .anyMatch(
+                        net -> net.getAugmentation(NetworkProviderExtension.class).getPhysicalNetwork() != null)) {
                     // add virtual router IP only in case it is provider physical network
                     sb.setVirtualRouterIp(subnet.getGatewayIp());
                 }
@@ -184,14 +187,15 @@ public class NeutronSubnetAware implements
         if (!Strings.isNullOrEmpty(subnet.getName())) {
             try {
                 ndb.setName(new Name(subnet.getName()));
-            } catch (Exception e) {
+            } catch (NullPointerException | IllegalArgumentException e) {
                 LOG.info("Name '{}' of Neutron Subnet '{}' is ignored.", subnet.getName(), subnet.getUuid().getValue());
                 LOG.debug("Name exception", e);
             }
         }
         ndb.setNetworkDomainId(new NetworkDomainId(subnet.getUuid().getValue()));
         ndb.setNetworkDomainType(MappingUtils.SUBNET);
-        ndb.setParent(MappingUtils.createParent(new NetworkDomainId(subnet.getNetworkId().getValue()), L2FloodDomain.class));
+        ndb.setParent(
+            MappingUtils.createParent(new NetworkDomainId(subnet.getNetworkId().getValue()), L2FloodDomain.class));
         ndb.addAugmentation(SubnetAugmentForwarding.class, new SubnetAugmentForwardingBuilder().setSubnet(sb.build())
             .build());
         return ndb.build();
@@ -230,7 +234,7 @@ public class NeutronSubnetAware implements
         if (!Strings.isNullOrEmpty(subnet.getName())) {
             try {
                 subnetBuilder.setName(new Name(subnet.getName()));
-            } catch (Exception e) {
+            } catch (NullPointerException | IllegalArgumentException e) {
                 LOG.info("Name '{}' of Neutron Subnet '{}' is ignored.", subnet.getName(),
                         subnet.getUuid().getValue());
                 LOG.debug("Name exception", e);
@@ -258,8 +262,8 @@ public class NeutronSubnetAware implements
         ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
         NetworkDomainId subnetId = new NetworkDomainId(neutronSubnet.getUuid().getValue());
         TenantId tenantId = new TenantId(neutronSubnet.getTenantId().getValue());
-        Optional<NetworkDomain> potentialSubnetDomain = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION,
-                L2L3IidFactory.subnetIid(tenantId, subnetId), rwTx);
+        Optional<NetworkDomain> potentialSubnetDomain = DataStoreHelper.removeIfExists(
+            LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.subnetIid(tenantId, subnetId), rwTx);
         if (!potentialSubnetDomain.isPresent()) {
             LOG.warn("Illegal state - subnet network domain {} does not exist.", subnetId.getValue());
             rwTx.cancel();
diff --git a/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/NeutronGbpMapperServiceImpl.java b/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/rule/NeutronGbpMapperServiceImpl.java
deleted file mode 100644 (file)
index 480831d..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.rule;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.groupbasedpolicy.neutron.mapper.util.SecurityRuleUtils;
-import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.ChangeActionOfSecurityGroupRulesInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.NeutronGbpMapperService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.change.action.of.security.group.rules.input.SecurityGroupRule;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
-
-public class NeutronGbpMapperServiceImpl implements NeutronGbpMapperService {
-
-    private static final Logger LOG = LoggerFactory.getLogger(NeutronGbpMapperServiceImpl.class);
-    private NeutronSecurityRuleAware secRuleAware;
-    private DataBroker dataProvider;
-
-    public NeutronGbpMapperServiceImpl(DataBroker dataProvider, NeutronSecurityRuleAware secRuleAware) {
-        this.dataProvider = checkNotNull(dataProvider);
-        this.secRuleAware = checkNotNull(secRuleAware);
-    }
-
-    @Override
-    public Future<RpcResult<Void>> changeActionOfSecurityGroupRules(ChangeActionOfSecurityGroupRulesInput input) {
-        List<SecurityGroupRule> securityGroupRules = input.getSecurityGroupRule();
-        if (securityGroupRules == null || input.getAction() == null) {
-            LOG.debug("Missing params in request:\n{}", input);
-            return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
-                .withError(ErrorType.PROTOCOL, "Missing params. Changing to action "
-                        + input.getAction().getActionChoice() + " was not successful.")
-                .build());
-        }
-
-        ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
-        Optional<Neutron> potentialNeutron;
-        try {
-            potentialNeutron = rwTx.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(Neutron.class).build()).get();
-        } catch (InterruptedException | ExecutionException e) {
-            LOG.error("Exception during neutron reading.", e);
-            return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
-                    .withError(ErrorType.PROTOCOL, "Cannot read from CONF DS.")
-                    .build());
-        }
-        if (!potentialNeutron.isPresent()) {
-            return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
-                    .withError(ErrorType.PROTOCOL, "No neutron data in CONF DS.")
-                    .build());
-        }
-        Neutron neutron = potentialNeutron.get();
-        for (SecurityGroupRule secGrpRule : securityGroupRules) {
-            Uuid uuid = secGrpRule.getUuid();
-            Optional<SecurityRule> potentialSecRule = SecurityRuleUtils.findSecurityRule(uuid, neutron.getSecurityRules());
-            if (!potentialSecRule.isPresent()) {
-                LOG.warn("Security rule {} does not exist.", uuid);
-                continue;
-            }
-            LOG.trace("Changing action to {} in security group rule {}", input.getAction().getActionChoice(), uuid);
-            boolean isSuccessful =
-                    secRuleAware.changeActionOfNeutronSecurityRule(potentialSecRule.get(), input.getAction().getActionChoice(), neutron, rwTx);
-            if (!isSuccessful) {
-                rwTx.cancel();
-                LOG.warn("Changing action to {} in security group rule {} was not successful.",
-                        input.getAction().getActionChoice(), uuid);
-                return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
-                    .withError(ErrorType.APPLICATION,
-                            "Changing to action " + input.getAction().getActionChoice() + " was not successful.")
-                    .build());
-            }
-        }
-        boolean isSubmittedToDs = DataStoreHelper.submitToDs(rwTx);
-        if (!isSubmittedToDs) {
-            LOG.warn("Changing action to {} in security group rules {} was not successful.",
-                    input.getAction().getActionChoice(), input.getSecurityGroupRule());
-            return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
-                .withError(ErrorType.APPLICATION, "Storing to datastore was not successful. Changing to action "
-                        + input.getAction().getActionChoice() + " was not successful.")
-                .build());
-        }
-        return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
-    }
-
-}
index 4ada5760619d5e24bc1e487c77e3896ab7be69d9..57ccc47e45ce0e942492796c40cc181fd2e89af6 100644 (file)
@@ -10,6 +10,14 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.rule;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.HashMultiset;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Multiset;
+import com.google.common.collect.Sets;
+
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -72,14 +80,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.HashMultiset;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Multiset;
-import com.google.common.collect.Sets;
-
 public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
 
     private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityRuleAware.class);
@@ -91,8 +91,8 @@ public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
     private final Multiset<InstanceIdentifier<ActionInstance>> createdActionInstances;
     private final Map<SecurityRuleKey, SecurityRule> pendingCreatedRules;
     private final Map<SecurityGroupKey, SecurityGroup> pendingDeletedGroups;
-    final static String PROVIDED_BY = "provided_by-";
-    final static String POSSIBLE_CONSUMER = "possible_consumer-";
+    private static final String PROVIDED_BY = "provided_by-";
+    private static final String POSSIBLE_CONSUMER = "possible_consumer-";
     private final EndpointRegistrator epRegistrator;
 
     public NeutronSecurityRuleAware(DataBroker dataProvider, EndpointRegistrator epRegistrator) {
@@ -175,9 +175,11 @@ public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
         Description contractDescription = createContractDescription(secRule, neutron);
         SingleRuleContract singleRuleContract = createSingleRuleContract(secRule, contractDescription, action, neutron);
         Contract contract = singleRuleContract.getContract();
-        rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, contract.getId()), contract, true);
+        rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, contract.getId()), contract,
+            true);
         SelectorName providerSelector = getSelectorNameWithConsumer(secRule, neutron);
-        writeProviderNamedSelectorToEpg(providerSelector, contract.getId(), new EpgKeyDto(providerEpgId, tenantId), rwTx);
+        writeProviderNamedSelectorToEpg(providerSelector, contract.getId(), new EpgKeyDto(providerEpgId, tenantId),
+            rwTx);
 
         if (secRule.getRemoteGroupId() != null) {
             Uuid consumerSecGroupId = secRule.getRemoteGroupId();
@@ -185,8 +187,10 @@ public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
             designContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, neutron, rwTx);
         } else {
             for (Uuid consumerSecGroupId : SecurityRuleUtils.findSecurityGroupsHavingSecurityRules(neutron)) {
-                designContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, neutron, rwTx);
-                designContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, neutron, rwTx);
+                designContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, neutron,
+                    rwTx);
+                designContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, neutron,
+                    rwTx);
             }
         }
 
@@ -220,16 +224,16 @@ public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
                     .filter(net -> NetworkUtils.isRouterExternal(net))
                     .findAny();
                 if (publicNet.isPresent()) {
-                    WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
-                    wTx.merge(LogicalDatastoreType.CONFIGURATION,
+                    WriteTransaction writeTx = dataProvider.newWriteOnlyTransaction();
+                    writeTx.merge(LogicalDatastoreType.CONFIGURATION,
                             IidFactory.externalImplicitGroupIid(new TenantId(secRule.getTenantId().getValue()),
                                     MappingUtils.EPG_EXTERNAL_ID),
                             new ExternalImplicitGroupBuilder().setId(MappingUtils.EPG_EXTERNAL_ID).build(), true);
-                    wTx.merge(LogicalDatastoreType.CONFIGURATION,
+                    writeTx.merge(LogicalDatastoreType.CONFIGURATION,
                             IidFactory.endpointGroupIid(new TenantId(secRule.getTenantId().getValue()),
                                     MappingUtils.EPG_EXTERNAL_ID),
                             new EndpointGroupBuilder().setId(MappingUtils.EPG_EXTERNAL_ID).build(), true);
-                    DataStoreHelper.submitToDs(wTx);
+                    DataStoreHelper.submitToDs(writeTx);
                     AddressEndpointRegBuilder addrEpbuilder = new AddressEndpointRegBuilder()
                         .setAddress(String.valueOf(secRule.getRemoteIpPrefix().getValue()))
                         .setAddressType(IpPrefixType.class)
@@ -271,8 +275,9 @@ public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
 
     @VisibleForTesting
     Set<SecurityRule> getProvidedSecRulesBetween(Uuid provSecGroup, Uuid consSecGroup, Neutron neutron) {
-        return Sets.union(SecurityRuleUtils.findSecurityRulesBySecGroupAndRemoteSecGroup(provSecGroup, consSecGroup, neutron),
-                SecurityRuleUtils.findSecurityRulesBySecGroupAndRemoteSecGroup(provSecGroup, null, neutron));
+        return Sets.union(
+            SecurityRuleUtils.findSecurityRulesBySecGroupAndRemoteSecGroup(provSecGroup, consSecGroup, neutron),
+            SecurityRuleUtils.findSecurityRulesBySecGroupAndRemoteSecGroup(provSecGroup, null, neutron));
     }
 
     @VisibleForTesting
@@ -289,7 +294,9 @@ public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
         return false;
     }
 
-    public boolean changeActionOfNeutronSecurityRule(SecurityRule secRule, ActionChoice action, Neutron neutron, ReadWriteTransaction rwTx) {
+    public boolean changeActionOfNeutronSecurityRule(SecurityRule secRule, ActionChoice action, Neutron neutron,
+        ReadWriteTransaction rwTx) {
+
         addSfcChainActionInstance(action, new TenantId(secRule.getTenantId().getValue()), rwTx);
         LOG.trace("Changing to action {} for secuirity group rule {}", action, secRule);
         return addNeutronSecurityRuleWithAction(secRule, neutron, action, rwTx);
@@ -313,32 +320,32 @@ public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
     }
 
     private void writeProviderNamedSelectorToEpg(SelectorName providerSelector, ContractId contractId, EpgKeyDto epgKey,
-            WriteTransaction wTx) {
+            WriteTransaction writeTx) {
         ProviderNamedSelector providerNamedSelector = new ProviderNamedSelectorBuilder().setName(providerSelector)
             .setContract(ImmutableList.of(contractId))
             .build();
-        wTx.put(LogicalDatastoreType.CONFIGURATION,
+        writeTx.put(LogicalDatastoreType.CONFIGURATION,
                 IidFactory.providerNamedSelectorIid(epgKey.getTenantId(), epgKey.getEpgId(),
                         providerNamedSelector.getName()), providerNamedSelector, true);
     }
 
     private void writeConsumerNamedSelectorToEpg(SelectorName consumerSelector, ContractId contractId, EpgKeyDto epgKey,
-            WriteTransaction wTx) {
+            WriteTransaction writeTx) {
         ConsumerNamedSelector consumerNamedSelector = new ConsumerNamedSelectorBuilder().setName(consumerSelector)
             .setContract(ImmutableList.of(contractId))
             .build();
-        wTx.put(LogicalDatastoreType.CONFIGURATION,
+        writeTx.put(LogicalDatastoreType.CONFIGURATION,
                 IidFactory.consumerNamedSelectorIid(epgKey.getTenantId(), epgKey.getEpgId(),
                         consumerNamedSelector.getName()), consumerNamedSelector, true);
     }
 
     @VisibleForTesting
     void createClassifierInstanceIfNotExists(TenantId tenantId, ClassifierInstance classifierInstance,
-            WriteTransaction wTx) {
+            WriteTransaction writeTx) {
         InstanceIdentifier<ClassifierInstance> classifierInstanceIid = IidFactory.classifierInstanceIid(tenantId,
                 classifierInstance.getName());
         if (!createdClassifierInstances.contains(classifierInstanceIid)) {
-            wTx.put(LogicalDatastoreType.CONFIGURATION, classifierInstanceIid, classifierInstance, true);
+            writeTx.put(LogicalDatastoreType.CONFIGURATION, classifierInstanceIid, classifierInstance, true);
         }
         createdClassifierInstances.add(classifierInstanceIid);
     }
@@ -408,12 +415,16 @@ public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
 
         if (secRule.getRemoteGroupId() != null) {
             Uuid consumerSecGroupId = secRule.getRemoteGroupId();
-            undesignContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, secRule, neutron, rwTx);
-            undesignContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, secRule, neutron, rwTx);
+            undesignContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, secRule,
+                neutron, rwTx);
+            undesignContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, secRule,
+                neutron, rwTx);
         } else {
             for (Uuid consumerSecGroupId : SecurityRuleUtils.findSecurityGroupsHavingSecurityRules(neutron)) {
-                undesignContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, secRule, neutron, rwTx);
-                undesignContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, secRule, neutron, rwTx);
+                undesignContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, secRule,
+                    neutron, rwTx);
+                undesignContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, secRule,
+                    neutron, rwTx);
             }
         }
 
@@ -432,7 +443,8 @@ public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
         Set<SecurityRule> consSecRules = getProvidedSecRulesBetween(consSecGroupId, provSecGroupId, neutron);
         EndpointGroupId consEpgId = new EndpointGroupId(consSecGroupId.getValue());
         for (SecurityRule provSecRule : provSecRules) {
-            if (isProvidersSecRuleSuitableForConsumersSecRulesAndGoodToRemove(provSecRule, consSecRules, removedSecRule)) {
+            if (isProvidersSecRuleSuitableForConsumersSecRulesAndGoodToRemove(provSecRule, consSecRules,
+                removedSecRule)) {
                 SelectorName consumerSelector = getSelectorNameWithProvider(provSecRule, neutron);
                 deleteConsumerNamedSelector(consumerSelector, new EpgKeyDto(consEpgId, tenantId), rwTx);
             }
@@ -552,17 +564,22 @@ public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
 
     @VisibleForTesting
     static boolean isOneWithinTwo(SecurityRule one, SecurityRule two) {
-        if (!isOneGroupIdWithinTwoRemoteGroupId(one, two) || !isOneGroupIdWithinTwoRemoteGroupId(two, one))
+        if (!isOneGroupIdWithinTwoRemoteGroupId(one, two) || !isOneGroupIdWithinTwoRemoteGroupId(two, one)) {
             return false;
-        if (!SecRuleEntityDecoder.isEtherTypeOfOneWithinTwo(one, two))
+        }
+        if (!SecRuleEntityDecoder.isEtherTypeOfOneWithinTwo(one, two)) {
             return false;
-        if (!SecRuleEntityDecoder.isProtocolOfOneWithinTwo(one, two))
+        }
+        if (!SecRuleEntityDecoder.isProtocolOfOneWithinTwo(one, two)) {
             return false;
-        if (!SecRuleEntityDecoder.isPortsOfOneWithinTwo(one, two))
+        }
+        if (!SecRuleEntityDecoder.isPortsOfOneWithinTwo(one, two)) {
             return false;
+        }
         if (two.getRemoteIpPrefix() != null
-                && one.getRemoteIpPrefix() == null)
+                && one.getRemoteIpPrefix() == null) {
             return false;
+        }
         return true;
     }
 
index c5255bbfdad06b18a05f8185d810da2783503081..6fe1d1ebe5e9971ca83c48dd11ebd77e06b2b932 100755 (executable)
@@ -10,6 +10,8 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.rule;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.collect.ImmutableList;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -50,7 +52,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV4;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmpV6;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
@@ -58,12 +59,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.SecurityRuleAttributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
 
-import com.google.common.collect.ImmutableList;
-
 public class SecRuleEntityDecoder {
 
     private SecRuleEntityDecoder() {
-        throw new UnsupportedOperationException("Cannot create an instace.");
+        throw new UnsupportedOperationException("Cannot create an instance.");
     }
 
     public static ContractId getContractId(SecurityRule secRule) {
@@ -82,7 +81,8 @@ public class SecRuleEntityDecoder {
                     .setIntValue(portMin.longValue())
                     .build());
             } else {
-                params.add(new ParameterValueBuilder().setName(new ParameterName(L4ClassifierDefinition.DST_PORT_RANGE_PARAM))
+                params.add(new ParameterValueBuilder()
+                    .setName(new ParameterName(L4ClassifierDefinition.DST_PORT_RANGE_PARAM))
                     .setRangeValue(
                             new RangeValueBuilder().setMin(portMin.longValue()).setMax(portMax.longValue()).build())
                     .build());
@@ -93,7 +93,8 @@ public class SecRuleEntityDecoder {
             if (classifierBuilder.getClassifierDefinitionId() == null) {
                 classifierBuilder.setClassifierDefinitionId(IpProtoClassifierDefinition.DEFINITION.getId());
             }
-            params.add(new ParameterValueBuilder().setName(new ParameterName(IpProtoClassifierDefinition.PROTO_PARAM))
+            params.add(new ParameterValueBuilder()
+                .setName(new ParameterName(IpProtoClassifierDefinition.PROTO_PARAM))
                 .setIntValue(protocol)
                 .build());
         }
@@ -102,7 +103,8 @@ public class SecRuleEntityDecoder {
             if (classifierBuilder.getClassifierDefinitionId() == null) {
                 classifierBuilder.setClassifierDefinitionId(EtherTypeClassifierDefinition.DEFINITION.getId());
             }
-            params.add(new ParameterValueBuilder().setName(new ParameterName(EtherTypeClassifierDefinition.ETHERTYPE_PARAM))
+            params.add(new ParameterValueBuilder()
+                .setName(new ParameterName(EtherTypeClassifierDefinition.ETHERTYPE_PARAM))
                 .setIntValue(ethertype)
                 .build());
         }
@@ -111,7 +113,7 @@ public class SecRuleEntityDecoder {
     }
 
     public static ActionRef createActionRefFromActionChoice(ActionChoice action) {
-        if(action instanceof SfcActionCase){
+        if (action instanceof SfcActionCase) {
             return MappingUtils.createSfcActionRef(((SfcActionCase) action).getSfcChainName());
         } else if (action instanceof AllowActionCase) {
             return MappingUtils.ACTION_REF_ALLOW;
@@ -131,7 +133,9 @@ public class SecRuleEntityDecoder {
     }
 
     /**
-     * @param secRule
+     * Resolves Direction for provided secRule.
+     *
+     * @param secRule rule for which Direction is resolved.
      * @return direction resolved from {@link SecurityRule#getDirection()}
      * @throws IllegalArgumentException if return value of
      *         {@link SecurityRule#getDirection()} is other than {@link DirectionIngress} or
@@ -153,6 +157,8 @@ public class SecRuleEntityDecoder {
     }
 
     /**
+     * Resolves Clause for provided secRule.
+     *
      * @param secRule {@link SecurityRule#getRemoteIpPrefix()} is used for EIC
      *        and subject selection
      * @return clause with the subject and with a consumer matcher containing EIC
@@ -160,8 +166,10 @@ public class SecRuleEntityDecoder {
     public static Clause getClause(SecurityRule secRule) {
         checkNotNull(secRule);
         SubjectName subjectName = SecRuleNameDecoder.getSubjectName(secRule);
-        ClauseBuilder clauseBuilder =
-                new ClauseBuilder().setSubjectRefs(ImmutableList.of(subjectName)).setName(SecRuleNameDecoder.getClauseName(secRule));
+        ClauseBuilder clauseBuilder = new ClauseBuilder()
+            .setSubjectRefs(ImmutableList.of(subjectName))
+            .setName(SecRuleNameDecoder
+                .getClauseName(secRule));
         IpPrefix remoteIpPrefix = secRule.getRemoteIpPrefix();
         if (remoteIpPrefix != null) {
             clauseBuilder.setConsumerMatchers(createConsumerMatchersWithEic(remoteIpPrefix));
@@ -192,10 +200,12 @@ public class SecRuleEntityDecoder {
     }
 
     private static <T> boolean twoIsNullOrEqualsOne(T one, T two) {
-        if (two == null)
+        if (two == null) {
             return true;
-        if (two.equals(one))
+        }
+        if (two.equals(one)) {
             return true;
+        }
         return false;
     }
 
@@ -215,7 +225,9 @@ public class SecRuleEntityDecoder {
     }
 
     /**
-     * @param secRule
+     * Resolves EtherType for provided secRule.
+     *
+     * @param secRule rule for which EtherType is resolved.
      * @return {@code null} if {@link SecurityRule#getEthertype()} is null; Otherwise ethertype
      *         number
      * @throws IllegalArgumentException if return value of
@@ -237,7 +249,9 @@ public class SecRuleEntityDecoder {
     }
 
     /**
-     * @param secRule
+     * Resolves Protocol for provided secRule.
+     *
+     * @param secRule rule for which Protocol is resolved.
      * @return {@code null} if {@link SecurityRule#getProtocol()} is null; Otherwise protocol number
      * @throws IllegalArgumentException if return value of
      *         {@link SecurityRule#getProtocol()} is other than {@link ProtocolTcp},
index 6ec2dc1dd49e3dea00d1fc170e562d6d272299aa..8ceafab886558a597e587d7475e83afe5528cd13 100644 (file)
@@ -20,14 +20,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SubjectName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.HasDirection.Direction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.SecurityRuleAttributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
 
 public class SecRuleNameDecoder {
 
-    final static String MIN_PORT = "_min";
-    final static String MAX_PORT = "_max";
+    static final String MIN_PORT = "_min";
+    static final String MAX_PORT = "_max";
 
     private SecRuleNameDecoder() {
         throw new UnsupportedOperationException("Cannot create an instance.");
index d17f1c9f5dd9e01171ec7d062c620bc50e639a45..1ae414403dc19d2d94ad3c7b916080a903e83ad6 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.rule;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableList;
+
 import java.util.List;
 
 import javax.annotation.concurrent.Immutable;
@@ -24,9 +27,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableList;
-
 @Immutable
 public class SingleClassifierRule {
 
@@ -110,14 +110,14 @@ public class SingleClassifierRule {
 
     private static boolean isRangePortParam(ParameterValue pv) {
         String pvName = pv.getName().getValue();
-        return pv.getRangeValue() != null
-                && (pvName.equals(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM) || pvName.equals(L4ClassifierDefinition.DST_PORT_RANGE_PARAM));
+        return pv.getRangeValue() != null && (pvName.equals(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM)
+            || pvName.equals(L4ClassifierDefinition.DST_PORT_RANGE_PARAM));
     }
 
     private static boolean isSrcOrDstPortParam(ParameterValue pv) {
         String pvName = pv.getName().getValue();
-        return pv.getIntValue() != null
-                && (pvName.equals(L4ClassifierDefinition.SRC_PORT_PARAM) || pvName.equals(L4ClassifierDefinition.DST_PORT_PARAM));
+        return pv.getIntValue() != null && (pvName.equals(L4ClassifierDefinition.SRC_PORT_PARAM)
+            || pvName.equals(L4ClassifierDefinition.DST_PORT_PARAM));
     }
 
 }
index 54103be7501c0340d9c6bcc33f11d60411c61062..1403357e2cf7aa9dd3f80f577bdede936728d5a5 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.rule;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.collect.ImmutableList;
+
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
 
@@ -23,8 +25,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.subject.Rule;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
 
-import com.google.common.collect.ImmutableList;
-
 @Immutable
 public class SingleRuleContract {
 
@@ -34,7 +34,8 @@ public class SingleRuleContract {
     private final Clause clause;
     private final Contract contract;
 
-    public SingleRuleContract(SecurityRule secRule, int subjectAndRuleOrder, @Nullable Description contractDescription, ActionChoice action) {
+    public SingleRuleContract(SecurityRule secRule, int subjectAndRuleOrder, @Nullable Description contractDescription,
+        ActionChoice action) {
         this(secRule, new SingleClassifierRule(secRule, subjectAndRuleOrder, action), contractDescription);
     }
 
index eff8541e5a4d35b81a1456049f6930d12e53a62b..c8ccfafcd651afcbf2090b08f80e764ad90634f4 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -21,9 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
 public class NetworkUtils {
 
     public static List<Network> findRouterExternalNetworks(@Nullable Networks networks) {
index 621f3b15daf65eaa5b0464deee5a38336ec23a7c..fc53e315bc046c832212987d60a193c4f82ee0ed 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
 
+import com.google.common.base.Optional;
+
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -22,8 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.por
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
 
-import com.google.common.base.Optional;
-
 public class PortUtils {
 
     public static final String DEVICE_OWNER_DHCP = "network:dhcp";
index cb6fe7c062a9d904aab1e23d0b7e8dfaae2d0d6b..c81cb7baf265d27b1a6fd941fb2a054e2198127a 100644 (file)
@@ -8,14 +8,14 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
 
+import com.google.common.base.Optional;
+
 import javax.annotation.Nullable;
 
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
 
-import com.google.common.base.Optional;
-
 public class RouterUtils {
 
     public static Optional<Router> findRouter(Uuid uuid, @Nullable Routers routers) {
index 0d28041cde53e39b09e00e4d1813c481d9bea46d..0c2a4e02a8a9f6eba928f2d05e664198309ce52b 100644 (file)
@@ -8,16 +8,16 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+
 import javax.annotation.Nullable;
 
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.SecurityGroups;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroup;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-
 public class SecurityGroupUtils {
 
     public static Optional<SecurityGroup> findSecurityGroup(Uuid secGrpUuid, @Nullable SecurityGroups securityGroups) {
index b85576306f08da4e89c848f6bc519ed4a26e34f1..f672a9791b9e3ec89c564afaed996a962ecb62a9 100644 (file)
@@ -8,6 +8,13 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
 
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
@@ -19,13 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.SecurityRules;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
 
-import com.google.common.base.Function;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.FluentIterable;
-
 public class SecurityRuleUtils {
 
     public static Optional<SecurityRule> findSecurityRule(Uuid uuid, @Nullable SecurityRules securityRules) {
index e368c9d70198c68e495bde39fa5e42a55cab90a2..5bef2bb1a8340bb70da514a65ad072c42cc8303d 100644 (file)
@@ -8,14 +8,14 @@
 
 package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
 
+import com.google.common.base.Optional;
+
 import javax.annotation.Nullable;
 
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
 
-import com.google.common.base.Optional;
-
 public class SubnetUtils {
 
     public static Optional<Subnet> findSubnet(Uuid uuid, @Nullable Subnets subnets) {
index 015ddfc0901b37874b2688ad279ba506fe76a6dd..4f3bb1faf02fefc2235a378462b6c5d1b2ce8ace 100644 (file)
@@ -9,6 +9,10 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.net.InetAddresses;
+
 import java.net.Inet4Address;
 import java.net.InetAddress;
 
@@ -31,10 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.floati
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.net.InetAddresses;
-
 public class Utils {
 
     private static final String MASK_32 = "/32";
index d053ca652dd76947fcf36519a73f5f888326b348..6190e6a3e1c134b614dd9a8acdabdf3b9ba772b9 100644 (file)
@@ -32,7 +32,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gb
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.BaseEndpointsByPorts;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.EndpointsByPorts;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.base.endpoints.by.ports.BaseEndpointByPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.base.endpoints.by.ports.BaseEndpointByPortKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.endpoints.by.ports.EndpointByPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.ExternalGatewaysAsEndpoints;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.ExternalGatewaysAsL3Endpoints;
@@ -53,8 +52,8 @@ public class NeutronGbpIidFactoryTest {
         UniqueId portId = mock(UniqueId.class);
         InstanceIdentifier<EndpointByPort> id = NeutronGbpIidFactory.endpointByPortIid(portId);
         assertNotNull(id);
-        Class<?>[] expectedTypes = {Mappings.class, GbpByNeutronMappings.class, EndpointsByPorts.class,
-                EndpointByPort.class};
+        Class<?>[] expectedTypes =
+            {Mappings.class, GbpByNeutronMappings.class, EndpointsByPorts.class, EndpointByPort.class};
         assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
         assertEquals(EndpointByPort.class, id.getTargetType());
         assertFalse(id.isWildcarded());
@@ -67,8 +66,8 @@ public class NeutronGbpIidFactoryTest {
         MacAddress mac = mock(MacAddress.class);
         InstanceIdentifier<PortByEndpoint> id = NeutronGbpIidFactory.portByEndpointIid(l2BdId, mac);
         assertNotNull(id);
-        Class<?>[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class, PortsByEndpoints.class,
-                PortByEndpoint.class};
+        Class<?>[] expectedTypes =
+            {Mappings.class, NeutronByGbpMappings.class, PortsByEndpoints.class, PortByEndpoint.class};
         assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
         assertEquals(PortByEndpoint.class, id.getTargetType());
         assertFalse(id.isWildcarded());
@@ -80,11 +79,12 @@ public class NeutronGbpIidFactoryTest {
     public void portByBaseEndpointIidTest() {
         String address = "00:00:00:00:00:00:01";
         ContextId ctxId = new ContextId("00000000-1111-2222-3333-44444555566667777");
-        PortByBaseEndpointKey key = new PortByBaseEndpointKey(address, MacAddressType.class, ctxId, MappingUtils.L2_BRDIGE_DOMAIN);
+        PortByBaseEndpointKey key =
+            new PortByBaseEndpointKey(address, MacAddressType.class, ctxId, MappingUtils.L2_BRDIGE_DOMAIN);
         InstanceIdentifier<PortByBaseEndpoint> id = NeutronGbpIidFactory.portByBaseEndpointIid(key);
         assertNotNull(id);
-        Class<?>[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class, PortsByBaseEndpoints.class,
-                PortByBaseEndpoint.class};
+        Class<?>[] expectedTypes =
+            {Mappings.class, NeutronByGbpMappings.class, PortsByBaseEndpoints.class, PortByBaseEndpoint.class};
         assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
         assertEquals(PortByBaseEndpoint.class, id.getTargetType());
         assertFalse(id.isWildcarded());
@@ -102,8 +102,8 @@ public class NeutronGbpIidFactoryTest {
 
         InstanceIdentifier<BaseEndpointByPort> id = NeutronGbpIidFactory.baseEndpointByPortIid(portId);
         assertNotNull(id);
-        Class<?>[] expectedTypes = {Mappings.class, GbpByNeutronMappings.class, BaseEndpointsByPorts.class,
-                BaseEndpointByPort.class};
+        Class<?>[] expectedTypes =
+            {Mappings.class, GbpByNeutronMappings.class, BaseEndpointsByPorts.class, BaseEndpointByPort.class};
         assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
         assertEquals(BaseEndpointByPort.class, id.getTargetType());
         assertFalse(id.isWildcarded());
@@ -117,7 +117,8 @@ public class NeutronGbpIidFactoryTest {
         InstanceIdentifier<ExternalGatewayAsL3Endpoint> id = NeutronGbpIidFactory.externalGatewayAsL3Endpoint(
                 l3Context, ipAddress);
         assertNotNull(id);
-        Class<?>[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class, ExternalGatewaysAsL3Endpoints.class,
+        Class<?>[] expectedTypes =
+            {Mappings.class, NeutronByGbpMappings.class, ExternalGatewaysAsL3Endpoints.class,
                 ExternalGatewayAsL3Endpoint.class};
         assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
         assertEquals(ExternalGatewayAsL3Endpoint.class, id.getTargetType());
@@ -133,22 +134,19 @@ public class NeutronGbpIidFactoryTest {
         String ipAddress = "192.168.50.20/32";
         IpPrefix ipPrefix = new IpPrefix(ipAddress.toCharArray());
         ContextId ctxId = new ContextId("00000000-1111-2222-3333-44444555566667777");
-        InstanceIdentifier<ExternalGatewayAsEndpoint> id = NeutronGbpIidFactory.externalGatewayAsEndpoint(
-                ctxId, ipPrefix, MappingUtils.L3_CONTEXT);
+        InstanceIdentifier<ExternalGatewayAsEndpoint> id =
+            NeutronGbpIidFactory.externalGatewayAsEndpoint(ctxId, ipPrefix, MappingUtils.L3_CONTEXT);
         assertNotNull(id);
-        Class<?>[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class, ExternalGatewaysAsEndpoints.class,
+        Class<?>[] expectedTypes =
+            {Mappings.class, NeutronByGbpMappings.class, ExternalGatewaysAsEndpoints.class,
                 ExternalGatewayAsEndpoint.class};
         assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
         assertEquals(ExternalGatewayAsEndpoint.class, id.getTargetType());
         assertFalse(id.isWildcarded());
-        assertEquals(ctxId, id.firstKeyOf(ExternalGatewayAsEndpoint.class)
-            .getContextId());
-        assertEquals(MappingUtils.L3_CONTEXT, id.firstKeyOf(ExternalGatewayAsEndpoint.class)
-                .getContextType());
-        assertEquals(ipAddress, id.firstKeyOf(ExternalGatewayAsEndpoint.class)
-            .getAddress());
-        assertEquals(IpPrefixType.class, id.firstKeyOf(ExternalGatewayAsEndpoint.class)
-                .getAddressType());
+        assertEquals(ctxId, id.firstKeyOf(ExternalGatewayAsEndpoint.class).getContextId());
+        assertEquals(MappingUtils.L3_CONTEXT, id.firstKeyOf(ExternalGatewayAsEndpoint.class).getContextType());
+        assertEquals(ipAddress, id.firstKeyOf(ExternalGatewayAsEndpoint.class).getAddress());
+        assertEquals(IpPrefixType.class, id.firstKeyOf(ExternalGatewayAsEndpoint.class).getAddressType());
     }
 
     private static void assertPathArgumentTypes(Iterable<PathArgument> pathArguments, Class<?>[] expectedTypes) {
index 5525dd436afc733f9f5f4c453f62e005473a3258..472737604c48fe489c0cdd3c35cf5f07dff64012 100644 (file)
@@ -16,6 +16,10 @@ import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
 import java.io.IOException;
 import java.util.Set;
 
@@ -53,10 +57,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroupBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
 public class NeutronMapperTest extends NeutronMapperDataBrokerTest {
 
     private final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
@@ -194,11 +194,11 @@ public class NeutronMapperTest extends NeutronMapperDataBrokerTest {
     }
 
     private Optional<L3Context> getL3ContextOptional(Network network) {
-        ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
+        ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
         TenantId tenantId = new TenantId(network.getTenantId().getValue());
         ContextId l3CtxId = new ContextId(network.getUuid().getValue());
         L3ContextId l3ContextId = new L3ContextId(l3CtxId);
         InstanceIdentifier<L3Context> l3ContextIid = IidFactory.l3ContextIid(tenantId, l3ContextId);
-        return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, rTx);
+        return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, readTx);
     }
 }
index e18818bd472a5e7ee3540373825267a88f89f08c..e81d7134f5324b10ef4af17eb657e62e1d309922 100644 (file)
@@ -14,11 +14,11 @@ import static org.junit.Assert.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import com.google.common.base.Optional;
+
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 
-import com.google.common.base.Optional;
-
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -29,8 +29,6 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronMapperDataBrokerTest;
 import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
 import org.opendaylight.groupbasedpolicy.util.IidFactory;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContextId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId;
@@ -49,7 +47,6 @@ public class NeutronNetworkAwareDataStoreTest extends NeutronMapperDataBrokerTes
     private final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
     private final Uuid networkUuid = new Uuid("dddddddd-dddd-dddd-dddd-dddddddddddd");
     private static final long METADATA_IPV4_SERVER_PORT = 80;
-    private static final IpPrefix METADATA_IP_PREFIX = new IpPrefix(new Ipv4Prefix("169.254.169.254/32"));
 
     private DataBroker dataBroker;
     private NeutronNetworkAware networkAware;
@@ -156,12 +153,12 @@ public class NeutronNetworkAwareDataStoreTest extends NeutronMapperDataBrokerTes
     }
 
     private Optional<L3Context> getL3ContextOptional(Network network) {
-        ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
+        ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
         TenantId tenantId = new TenantId(network.getTenantId().getValue());
         ContextId l3CtxId = new ContextId(network.getUuid().getValue());
         L3ContextId l3ContextId = new L3ContextId(l3CtxId);
         InstanceIdentifier<L3Context> l3ContextIid = IidFactory.l3ContextIid(tenantId, l3ContextId);
-        return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, rTx);
+        return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, readTx);
     }
 
 }
index 61cd99d7dda643083bff0eb84b18941ac05a656d..5208ceba4f7e28caa0efe7698bf3a080e8946a61 100644 (file)
@@ -12,6 +12,8 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import com.google.common.collect.ImmutableList;
+
 import java.util.Collections;
 import java.util.List;
 
@@ -45,8 +47,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.s
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetBuilder;
 
-import com.google.common.collect.ImmutableList;
-
 public class NeutronPortAwareDataStoreTest extends NeutronMapperDataBrokerTest {
 
     private final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
@@ -61,18 +61,20 @@ public class NeutronPortAwareDataStoreTest extends NeutronMapperDataBrokerTest {
     private Neutron neutron;
 
     @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() {
         dataBroker = getDataBroker();
         neutron = mock(Neutron.class);
         epRegistrator = mock(EndpointRegistrator.class);
         when(epRegistrator.registerEndpoint(any(RegisterEndpointInput.class))).thenReturn(true);
         when(epRegistrator.registerEndpoint(
-                any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput.class)))
-                    .thenReturn(true);
+            any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput.class)))
+            .thenReturn(true);
         when(epRegistrator.unregisterEndpoint(any(UnregisterEndpointInput.class))).thenReturn(true);
         when(epRegistrator.unregisterEndpoint(
-                any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput.class)))
-                    .thenReturn(true);
+            any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput.class)))
+            .thenReturn(true);
 
         portAware = new NeutronPortAware(dataBroker, epRegistrator, new IpPrefix(new Ipv4Prefix("192.168.192.168/32")));
     }
index 813d8df7d0b52a0c53b5341d60e52f9144eecc7c..e6aa72d9eab046ed2b5218f75131cf5b6cc800c5 100644 (file)
@@ -15,11 +15,12 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -33,9 +34,7 @@ import org.opendaylight.groupbasedpolicy.neutron.mapper.util.Utils;
 import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
 import org.opendaylight.groupbasedpolicy.util.IidFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.BaseEndpointService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContextId;
@@ -64,15 +63,14 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 
 public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest {
 
-    private final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
-    private final Uuid routerUuid = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
-    private final Uuid newRouterUuid = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbb2");
-    private final Uuid subnetUuid = new Uuid("cccccccc-cccc-cccc-cccc-cccccccccccc");
-    private final Uuid networkUuid = new Uuid("dddddddd-dddd-dddd-dddd-dddddddddddd");
-    private final Uuid gatewayPortUuid = new Uuid("dddddddd-dddd-dddd-dddd-ddddddddddd1");
-    private final IpAddress ipAddress = new IpAddress(new Ipv4Address("10.0.0.2"));
+    private static final Uuid TENANT_UUID = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
+    private static final Uuid ROUTER_UUID = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
+    private static final Uuid NEW_ROUTER_UUID = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbb2");
+    private static final Uuid SUBNET_UUID = new Uuid("cccccccc-cccc-cccc-cccc-cccccccccccc");
+    private static final Uuid NETWORK_UUID = new Uuid("dddddddd-dddd-dddd-dddd-dddddddddddd");
+    private static final Uuid GATEWAY_PORT_UUID = new Uuid("dddddddd-dddd-dddd-dddd-ddddddddddd1");
+    private static final IpAddress IP_ADDRESS = new IpAddress(new Ipv4Address("10.0.0.2"));
     private static final long METADATA_IPV4_SERVER_PORT = 80;
-    private static final IpPrefix METADATA_IP_PREFIX = new IpPrefix(new Ipv4Prefix("169.254.169.254/32"));
 
     private DataBroker dataBroker;
     private NeutronRouterAware routerAware;
@@ -88,6 +86,8 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
     private Network network;
 
     @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);
         futureRpcFail = mock(Future.class);
@@ -113,7 +113,7 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
         epRegistrator = new EndpointRegistrator(epService, baseEpService);
 
         networkAware = new NeutronNetworkAware(dataBroker, METADATA_IPV4_SERVER_PORT);
-        network = new NetworkBuilder().setTenantId(tenantUuid).setUuid(networkUuid).setName("networkName").build();
+        network = new NetworkBuilder().setTenantId(TENANT_UUID).setUuid(NETWORK_UUID).setName("networkName").build();
 
         routerAware = new NeutronRouterAware(dataBroker, epRegistrator);
     }
@@ -129,7 +129,7 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
 
     @Test
     public void testOnCreated() {
-        Router router = new RouterBuilder().setTenantId(tenantUuid).setName("routerName").setUuid(routerUuid).build();
+        Router router = new RouterBuilder().setTenantId(TENANT_UUID).setName("routerName").setUuid(ROUTER_UUID).build();
 
         routerAware.onCreated(router, neutron);
 
@@ -138,7 +138,7 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
 
     @Test
     public void testOnCreated_incorrectName() {
-        Router router = new RouterBuilder().setTenantId(tenantUuid).setName("123").setUuid(routerUuid).build();
+        Router router = new RouterBuilder().setTenantId(TENANT_UUID).setName("123").setUuid(ROUTER_UUID).build();
 
         routerAware.onCreated(router, neutron);
 
@@ -151,18 +151,13 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
         when(neutron.getSubnets()).thenReturn(subnets);
         when(neutron.getNetworks()).thenReturn(new NetworksBuilder().setNetwork(ImmutableList.of(network)).build());
 
-        FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(ipAddress).setSubnetId(subnetUuid).build();
-        Port port = new PortBuilder().setUuid(gatewayPortUuid).setFixedIps(ImmutableList.of(fixedIps)).build();
+        FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(IP_ADDRESS).setSubnetId(SUBNET_UUID).build();
+        Port port = new PortBuilder().setUuid(GATEWAY_PORT_UUID).setFixedIps(ImmutableList.of(fixedIps)).build();
         Ports ports = new PortsBuilder().setPort(ImmutableList.of(port)).build();
         when(neutron.getPorts()).thenReturn(ports);
 
         Router oldRouter =
-                new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
-        Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
-            .setName("newRouterName")
-            .setUuid(newRouterUuid)
-            .setGatewayPortId(gatewayPortUuid)
-            .build();
+                new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
 
         networkAware.onCreated(network, neutron);
 
@@ -171,6 +166,13 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
         routerAware.onCreated(oldRouter, neutron);
 
         assertRouterExists(oldRouter);
+
+        Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
+            .setName("newRouterName")
+            .setUuid(NEW_ROUTER_UUID)
+            .setGatewayPortId(GATEWAY_PORT_UUID)
+            .build();
+
         assertRouterNotExists(newRouter);
 
         routerAware.onUpdated(oldRouter, newRouter, neutron, neutron);
@@ -184,7 +186,7 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
         Subnets subnets = createSubnets();
         when(neutron.getSubnets()).thenReturn(subnets);
 
-        FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(ipAddress).setSubnetId(subnetUuid).build();
+        FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(IP_ADDRESS).setSubnetId(SUBNET_UUID).build();
         Port port = new PortBuilder().setUuid(new Uuid("dddddddd-dddd-dddd-dddd-000000000000"))
             .setFixedIps(ImmutableList.of(fixedIps))
             .build();
@@ -192,11 +194,11 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
         when(neutron.getPorts()).thenReturn(ports);
 
         Router oldRouter =
-                new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
-        Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
+                new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
+        Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
             .setName("newRouterName")
-            .setUuid(newRouterUuid)
-            .setGatewayPortId(gatewayPortUuid)
+            .setUuid(NEW_ROUTER_UUID)
+            .setGatewayPortId(GATEWAY_PORT_UUID)
             .build();
 
         routerAware.onCreated(oldRouter, neutron);
@@ -210,16 +212,16 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
         Subnets subnets = createSubnets();
         when(neutron.getSubnets()).thenReturn(subnets);
 
-        Port port = new PortBuilder().setUuid(gatewayPortUuid).build();
+        Port port = new PortBuilder().setUuid(GATEWAY_PORT_UUID).build();
         Ports ports = new PortsBuilder().setPort(ImmutableList.of(port)).build();
         when(neutron.getPorts()).thenReturn(ports);
 
         Router oldRouter =
-                new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
-        Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
+                new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
+        Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
             .setName("newRouterName")
-            .setUuid(newRouterUuid)
-            .setGatewayPortId(gatewayPortUuid)
+            .setUuid(NEW_ROUTER_UUID)
+            .setGatewayPortId(GATEWAY_PORT_UUID)
             .build();
 
         routerAware.onCreated(oldRouter, neutron);
@@ -233,17 +235,17 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
         Subnets subnets = createSubnets();
         when(neutron.getSubnets()).thenReturn(subnets);
 
-        FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(ipAddress).build();
-        Port port = new PortBuilder().setUuid(gatewayPortUuid).setFixedIps(ImmutableList.of(fixedIps)).build();
+        FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(IP_ADDRESS).build();
+        Port port = new PortBuilder().setUuid(GATEWAY_PORT_UUID).setFixedIps(ImmutableList.of(fixedIps)).build();
         Ports ports = new PortsBuilder().setPort(ImmutableList.of(port)).build();
         when(neutron.getPorts()).thenReturn(ports);
 
         Router oldRouter =
-                new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
-        Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
+                new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
+        Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
             .setName("newRouterName")
-            .setUuid(newRouterUuid)
-            .setGatewayPortId(gatewayPortUuid)
+            .setUuid(NEW_ROUTER_UUID)
+            .setGatewayPortId(GATEWAY_PORT_UUID)
             .build();
 
         routerAware.onCreated(oldRouter, neutron);
@@ -253,6 +255,8 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
     }
 
     @Test
+    @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 testOnUpdated_ExtGatewayNotRegistered() {
         when(baseEpService.registerEndpoint(
                 any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.RegisterEndpointInput.class)))
@@ -261,17 +265,17 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
         Subnets subnets = createSubnets();
         when(neutron.getSubnets()).thenReturn(subnets);
 
-        FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(ipAddress).setSubnetId(subnetUuid).build();
-        Port port = new PortBuilder().setUuid(gatewayPortUuid).setFixedIps(ImmutableList.of(fixedIps)).build();
+        FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(IP_ADDRESS).setSubnetId(SUBNET_UUID).build();
+        Port port = new PortBuilder().setUuid(GATEWAY_PORT_UUID).setFixedIps(ImmutableList.of(fixedIps)).build();
         Ports ports = new PortsBuilder().setPort(ImmutableList.of(port)).build();
         when(neutron.getPorts()).thenReturn(ports);
 
         Router oldRouter =
-                new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
-        Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
+                new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
+        Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
             .setName("newRouterName")
-            .setUuid(newRouterUuid)
-            .setGatewayPortId(gatewayPortUuid)
+            .setUuid(NEW_ROUTER_UUID)
+            .setGatewayPortId(GATEWAY_PORT_UUID)
             .build();
 
         routerAware.onCreated(oldRouter, neutron);
@@ -286,17 +290,17 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
         when(neutron.getSubnets()).thenReturn(subnets);
         when(neutron.getNetworks()).thenReturn(new NetworksBuilder().setNetwork(ImmutableList.of(network)).build());
 
-        FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(ipAddress).setSubnetId(subnetUuid).build();
-        Port port = new PortBuilder().setUuid(gatewayPortUuid).setFixedIps(ImmutableList.of(fixedIps)).build();
+        FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(IP_ADDRESS).setSubnetId(SUBNET_UUID).build();
+        Port port = new PortBuilder().setUuid(GATEWAY_PORT_UUID).setFixedIps(ImmutableList.of(fixedIps)).build();
         Ports ports = new PortsBuilder().setPort(ImmutableList.of(port)).build();
         when(neutron.getPorts()).thenReturn(ports);
 
         Router oldRouter =
-                new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
-        Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
+                new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
+        Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
             .setName("newRouterName")
-            .setUuid(newRouterUuid)
-            .setGatewayPortId(gatewayPortUuid)
+            .setUuid(NEW_ROUTER_UUID)
+            .setGatewayPortId(GATEWAY_PORT_UUID)
             .build();
 
         routerAware.onCreated(oldRouter, neutron);
@@ -308,7 +312,7 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
     @Test
     public void testOnDeleted() {
         Router router =
-                new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
+                new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
 
         routerAware.onCreated(router, neutron);
         routerAware.onDeleted(router, neutron, neutron);
@@ -316,11 +320,11 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
     }
 
     private Subnets createSubnets() {
-        Subnet subnet = new SubnetBuilder().setTenantId(tenantUuid)
-            .setUuid(subnetUuid)
+        Subnet subnet = new SubnetBuilder().setTenantId(TENANT_UUID)
+            .setUuid(SUBNET_UUID)
             .setName("subnetName")
-            .setNetworkId(networkUuid)
-            .setGatewayIp(ipAddress)
+            .setNetworkId(NETWORK_UUID)
+            .setGatewayIp(IP_ADDRESS)
             .setCidr(Utils.createIpPrefix("10.0.0.0/24"))
             .build();
         return new SubnetsBuilder().setSubnet(ImmutableList.of(subnet)).build();
@@ -343,12 +347,12 @@ public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest
     }
 
     private Optional<L3Context> getL3ContextOptional(Router router) {
-        ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
+        ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
         TenantId tenantId = new TenantId(router.getTenantId().getValue());
         ContextId routerL3CtxId = new ContextId(router.getUuid().getValue());
         L3ContextId l3ContextId = new L3ContextId(routerL3CtxId);
         InstanceIdentifier<L3Context> l3ContextIid = IidFactory.l3ContextIid(tenantId, l3ContextId);
-        return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, rTx);
+        return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, readTx);
     }
 
 }
index c4bfd09b6b23a16afc593b46ac91e26d00d0ff5b..069a37e9605bbe8937fd76458e3de2cecc43223b 100644 (file)
@@ -12,16 +12,15 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import org.apache.commons.lang3.StringUtils;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronMapperDataBrokerTest;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.EndpointRegistrator;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.rule.NeutronSecurityRuleAware;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronEntityFactory;
+import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronMapperDataBrokerTest;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.test.PolicyAssert;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.util.MappingUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
@@ -44,6 +43,8 @@ public class NeutronSecurityGroupAwareDataStoreTest extends NeutronMapperDataBro
     private EndpointRegistrator epRegistrator;
 
     @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() {
         dataBroker = getDataBroker();
 
@@ -136,7 +137,6 @@ public class NeutronSecurityGroupAwareDataStoreTest extends NeutronMapperDataBro
     @Test
     public void testAddNeutronSecurityGroup_incorrectNameDescription() throws Exception {
         String uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd";
-        String longDescription = StringUtils.repeat("a", 4100);
         SecurityGroup secGroupA = new SecurityGroupBuilder().setUuid(new Uuid(uuid))
             .setTenantId(new Uuid(tenantId))
             .setName("123")
index f337fd83f13a00892e1e5f7cf62ca866f3213cee..54d6c16cd12a7c21b42d81cd68ed539a1adf9be5 100644 (file)
@@ -12,6 +12,8 @@ import static org.mockito.Matchers.any;
 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;
 
@@ -41,17 +43,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.s
 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;
@@ -62,22 +62,24 @@ public class NeutronSubnetAwareDataStoreTest extends NeutronMapperDataBrokerTest
     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);
@@ -115,15 +117,15 @@ public class NeutronSubnetAwareDataStoreTest extends NeutronMapperDataBrokerTest
 
         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
@@ -132,57 +134,58 @@ public class NeutronSubnetAwareDataStoreTest extends NeutronMapperDataBrokerTest
         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);
     }
 
 }
index 5e73207974fe0b84ca156cef83af9e1be87243d0..0ae15608472bbbfd03276800750c95094051deeb 100644 (file)
@@ -10,6 +10,10 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.rule;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -47,13 +51,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRuleBuilder;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
 /**
- * END 2 END TESTING - inputs are Neutron entities and expected outputs are GBP entities in
- * datastore
+ * END 2 END TESTING - inputs are Neutron entities and expected outputs are GBP entities in datastore.
  */
 
 public class NeutronSecurityRuleAwareDataStoreTest extends NeutronMapperDataBrokerTest {
@@ -67,36 +66,38 @@ public class NeutronSecurityRuleAwareDataStoreTest extends NeutronMapperDataBrok
 
     @Test
     public final void testAddNeutronSecurityRule_rulesWithRemoteIpPrefix() throws Exception {
-        String tenant = "ad4c6c25-2424-4ad3-97ee-f9691ce03645";
-        String goldSecGrp = "fe40e28f-ad6a-4a2d-b12a-47510876344a";
-        SecurityRule goldInIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant, EthertypeV4.class, DirectionIngress.class, goldSecGrp,
-                null);
-        SecurityRule goldOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant, EthertypeV4.class, DirectionEgress.class, goldSecGrp,
-                null);
-        String serverSecGrp = "71cf4fe5-b146-409e-8151-cd921298ce32";
-        SecurityRuleAttributes.Protocol protocolTcp = new SecurityRuleAttributes.Protocol(ProtocolTcp.class);
-        SecurityRule serverIn80Tcp10_1_1_0 = new SecurityRuleBuilder().setUuid(new Uuid("9dbb533d-d9b2-4dc9-bae7-ee60c8df184d"))
-                .setTenantId(new Uuid(tenant))
-                .setEthertype(EthertypeV4.class)
-                .setProtocol(protocolTcp)
-                .setPortRangeMin(80)
-                .setPortRangeMax(80)
-                .setDirection(DirectionIngress.class)
-                .setSecurityGroupId(new Uuid(serverSecGrp))
-                .setRemoteIpPrefix(new IpPrefix(new Ipv4Prefix("10.1.1.0/24")))
-                .build();
-        SecurityRule serverInIp20_1_1_0 = new SecurityRuleBuilder().setUuid(new Uuid("adf7e558-de47-4f9e-a9b8-96e19db5d1ac"))
-                .setTenantId(new Uuid(tenant))
-                .setEthertype(EthertypeV4.class)
-                .setDirection(DirectionIngress.class)
-                .setSecurityGroupId(new Uuid(serverSecGrp))
-                .setRemoteIpPrefix(new IpPrefix(new Ipv4Prefix("20.1.1.0/24")))
-                .build();
-        SecurityRule serverOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "8b9c48d3-44a8-46be-be35-6f3237d98071", tenant, EthertypeV4.class, DirectionEgress.class, serverSecGrp,
-                null);
+        final String tenant = "ad4c6c25-2424-4ad3-97ee-f9691ce03645";
+        final String goldSecGrp = "fe40e28f-ad6a-4a2d-b12a-47510876344a";
+        final SecurityRule goldInIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
+            "166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant, EthertypeV4.class, DirectionIngress.class, goldSecGrp,
+            null);
+        final SecurityRule goldOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
+            "dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant, EthertypeV4.class, DirectionEgress.class, goldSecGrp,
+            null);
+        final String serverSecGrp = "71cf4fe5-b146-409e-8151-cd921298ce32";
+        final SecurityRuleAttributes.Protocol protocolTcp = new SecurityRuleAttributes.Protocol(ProtocolTcp.class);
+        final SecurityRule serverIn80Tcp10_1_1_0 = new SecurityRuleBuilder()
+            .setUuid(new Uuid("9dbb533d-d9b2-4dc9-bae7-ee60c8df184d"))
+            .setTenantId(new Uuid(tenant))
+            .setEthertype(EthertypeV4.class)
+            .setProtocol(protocolTcp)
+            .setPortRangeMin(80)
+            .setPortRangeMax(80)
+            .setDirection(DirectionIngress.class)
+            .setSecurityGroupId(new Uuid(serverSecGrp))
+            .setRemoteIpPrefix(new IpPrefix(new Ipv4Prefix("10.1.1.0/24")))
+            .build();
+        final SecurityRule serverInIp20_1_1_0 = new SecurityRuleBuilder()
+            .setUuid(new Uuid("adf7e558-de47-4f9e-a9b8-96e19db5d1ac"))
+            .setTenantId(new Uuid(tenant))
+            .setEthertype(EthertypeV4.class)
+            .setDirection(DirectionIngress.class)
+            .setSecurityGroupId(new Uuid(serverSecGrp))
+            .setRemoteIpPrefix(new IpPrefix(new Ipv4Prefix("20.1.1.0/24")))
+            .build();
+        final SecurityRule serverOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
+            "8b9c48d3-44a8-46be-be35-6f3237d98071", tenant, EthertypeV4.class, DirectionEgress.class, serverSecGrp,
+            null);
         DataBroker dataBroker = getDataBroker();
         List<SecurityGroup> secGroups = new ArrayList<>();
         secGroups.add(NeutronEntityFactory.securityGroup(goldSecGrp, tenant));
@@ -175,12 +176,12 @@ public class NeutronSecurityRuleAwareDataStoreTest extends NeutronMapperDataBrok
         final String secRuleId1 = "dddddddd-dddd-dddd-dddd-dddddddddddd";
         final String secRuleId2 = "eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee";
 
-        List<SecurityGroup> secGroups = new ArrayList<>();
+        final List<SecurityGroup> secGroups = new ArrayList<>();
         secGroups.add(NeutronEntityFactory.securityGroup(secGroupId1, tenantId));
         secGroups.add(NeutronEntityFactory.securityGroup(secGroupId2, tenantId));
-        SecurityRule secRule1 = NeutronEntityFactory.securityRuleWithEtherType(secRuleId1, tenantId,
+        final SecurityRule secRule1 = NeutronEntityFactory.securityRuleWithEtherType(secRuleId1, tenantId,
                 EthertypeV4.class, DirectionEgress.class, secGroupId1, secGroupId2);
-        SecurityRule secRule2 = NeutronEntityFactory.securityRuleWithEtherType(secRuleId2, tenantId,
+        final SecurityRule secRule2 = NeutronEntityFactory.securityRuleWithEtherType(secRuleId2, tenantId,
                 EthertypeV4.class, DirectionIngress.class, secGroupId2, secGroupId1);
         NeutronBuilder neutronBuilder = new NeutronBuilder()
             .setSecurityGroups(new SecurityGroupsBuilder().setSecurityGroup(secGroups).build())
@@ -269,19 +270,19 @@ public class NeutronSecurityRuleAwareDataStoreTest extends NeutronMapperDataBrok
     public final void testAddNeutronSecurityRule_rulesWithoutRemote() throws Exception {
         String tenant = "ad4c6c25-2424-4ad3-97ee-f9691ce03645";
         String goldSecGrp = "fe40e28f-ad6a-4a2d-b12a-47510876344a";
-        SecurityRule goldInIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant, EthertypeV4.class, DirectionIngress.class, goldSecGrp,
-                null);
-        SecurityRule goldOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant, EthertypeV4.class, DirectionEgress.class, goldSecGrp,
-                null);
+        SecurityRule goldInIpv4 =
+            NeutronEntityFactory.securityRuleWithEtherType("166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant,
+                EthertypeV4.class, DirectionIngress.class, goldSecGrp, null);
+        SecurityRule goldOutIpv4 =
+            NeutronEntityFactory.securityRuleWithEtherType("dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant,
+                EthertypeV4.class, DirectionEgress.class, goldSecGrp, null);
         String serverSecGrp = "71cf4fe5-b146-409e-8151-cd921298ce32";
-        SecurityRule serverOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "8b9c48d3-44a8-46be-be35-6f3237d98071", tenant, EthertypeV4.class, DirectionEgress.class, serverSecGrp,
-                null);
-        SecurityRule serverInIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "adf7e558-de47-4f9e-a9b8-96e19db5d1ac", tenant, EthertypeV4.class, DirectionIngress.class, serverSecGrp,
-                null);
+        SecurityRule serverOutIpv4 =
+            NeutronEntityFactory.securityRuleWithEtherType("8b9c48d3-44a8-46be-be35-6f3237d98071", tenant,
+                EthertypeV4.class, DirectionEgress.class, serverSecGrp, null);
+        SecurityRule serverInIpv4 =
+            NeutronEntityFactory.securityRuleWithEtherType("adf7e558-de47-4f9e-a9b8-96e19db5d1ac", tenant,
+                EthertypeV4.class, DirectionIngress.class, serverSecGrp, null);
         DataBroker dataBroker = getDataBroker();
         List<SecurityGroup> secGroups = new ArrayList<>();
         secGroups.add(NeutronEntityFactory.securityGroup(goldSecGrp, tenant));
@@ -344,25 +345,26 @@ public class NeutronSecurityRuleAwareDataStoreTest extends NeutronMapperDataBrok
         String tenant = "ad4c6c25-2424-4ad3-97ee-f9691ce03645";
         String goldSecGrp = "fe40e28f-ad6a-4a2d-b12a-47510876344a";
         SecurityRule goldInIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant, EthertypeV4.class, DirectionIngress.class, goldSecGrp,
-                null);
+            "166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant, EthertypeV4.class, DirectionIngress.class, goldSecGrp,
+            null);
         SecurityRule goldOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant, EthertypeV4.class, DirectionEgress.class, goldSecGrp,
-                null);
+            "dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant, EthertypeV4.class, DirectionEgress.class, goldSecGrp,
+            null);
         String serverSecGrp = "71cf4fe5-b146-409e-8151-cd921298ce32";
         SecurityRule serverOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "8b9c48d3-44a8-46be-be35-6f3237d98071", tenant, EthertypeV4.class, DirectionEgress.class, serverSecGrp,
-                null);
+            "8b9c48d3-44a8-46be-be35-6f3237d98071", tenant, EthertypeV4.class, DirectionEgress.class, serverSecGrp,
+            null);
         SecurityRuleAttributes.Protocol protocolTcp = new SecurityRuleAttributes.Protocol(ProtocolTcp.class);
-        SecurityRule serverIn80TcpIpv4 = new SecurityRuleBuilder().setUuid(new Uuid("adf7e558-de47-4f9e-a9b8-96e19db5d1ac"))
-                .setTenantId(new Uuid(tenant))
-                .setEthertype(EthertypeV4.class)
-                .setProtocol(protocolTcp)
-                .setPortRangeMin(80)
-                .setPortRangeMax(80)
-                .setDirection(DirectionIngress.class)
-                .setSecurityGroupId(new Uuid(serverSecGrp))
-                .build();
+        SecurityRule serverIn80TcpIpv4 = new SecurityRuleBuilder()
+            .setUuid(new Uuid("adf7e558-de47-4f9e-a9b8-96e19db5d1ac"))
+            .setTenantId(new Uuid(tenant))
+            .setEthertype(EthertypeV4.class)
+            .setProtocol(protocolTcp)
+            .setPortRangeMin(80)
+            .setPortRangeMax(80)
+            .setDirection(DirectionIngress.class)
+            .setSecurityGroupId(new Uuid(serverSecGrp))
+            .build();
         DataBroker dataBroker = getDataBroker();
         List<SecurityGroup> secGroups = new ArrayList<>();
         secGroups.add(NeutronEntityFactory.securityGroup(goldSecGrp, tenant));
@@ -421,20 +423,20 @@ public class NeutronSecurityRuleAwareDataStoreTest extends NeutronMapperDataBrok
 
     @Test
     public final void testAddNeutronSecurityRule_defaultSecGrp() throws Exception {
-        String tenant = "111aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa";
-        String defaultSecGrp = "111fffff-ffff-ffff-ffff-ffffffffffff";
-        SecurityRule defaultInIpv4Default = NeutronEntityFactory.securityRuleWithEtherType(
-                "111ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionIngress.class, defaultSecGrp,
-                defaultSecGrp);
-        SecurityRule defaultInIpv6Default = NeutronEntityFactory.securityRuleWithEtherType(
-                "222ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionIngress.class, defaultSecGrp,
-                defaultSecGrp);
-        SecurityRule defaultOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
-                "333ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionEgress.class, defaultSecGrp,
-                null);
-        SecurityRule defaultOutIpv6 = NeutronEntityFactory.securityRuleWithEtherType(
-                "444ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionEgress.class, defaultSecGrp,
-                null);
+        final String tenant = "111aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa";
+        final String defaultSecGrp = "111fffff-ffff-ffff-ffff-ffffffffffff";
+        final SecurityRule defaultInIpv4Default = NeutronEntityFactory.securityRuleWithEtherType(
+            "111ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionIngress.class, defaultSecGrp,
+            defaultSecGrp);
+        final SecurityRule defaultInIpv6Default = NeutronEntityFactory.securityRuleWithEtherType(
+            "222ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionIngress.class, defaultSecGrp,
+            defaultSecGrp);
+        final SecurityRule defaultOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
+            "333ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionEgress.class, defaultSecGrp,
+            null);
+        final SecurityRule defaultOutIpv6 = NeutronEntityFactory.securityRuleWithEtherType(
+            "444ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionEgress.class, defaultSecGrp,
+            null);
         DataBroker dataBroker = getDataBroker();
         List<SecurityGroup> secGroups = new ArrayList<>();
         secGroups.add(NeutronEntityFactory.securityGroup(defaultSecGrp, tenant));
index 0f0951ee00f34eb50b0ff99c460707f72796157e..514fca9bb394d99506e8a467d5d498faacfed394 100644 (file)
@@ -21,8 +21,8 @@ import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.EndpointRegistrator;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.test.ConfigDataStoreReader;
-import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronMapperDataBrokerTest;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronEntityFactory;
+import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronMapperDataBrokerTest;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.test.PolicyAssert;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
index 4510aee6c4623d195d4397d3a491966a18bbbd50..dffd5025923490594b476f207818728e3cc49f49 100644 (file)
@@ -154,8 +154,6 @@ public class SecRuleEntityDecoderTest {
             .append(MappingUtils.NAME_VALUE_DELIMETER)
             .append(EthertypeV4.class.getSimpleName())
             .toString();
-        System.out.println(expectedName);
-        System.out.println(ci.getName().getValue());
         Assert.assertEquals(expectedName, ci.getName().getValue());
         List<ParameterValue> parameterValues = ci.getParameterValue();
         Assert.assertNotNull(parameterValues);
@@ -184,7 +182,7 @@ public class SecRuleEntityDecoderTest {
         Assert.assertTrue("Classifier-instance does not contain destination port parameter", containsDstPortParam);
     }
 
-    private final void assertClassifierParameterValue(ParameterValue parameter, Long expectedIntValue,
+    private void assertClassifierParameterValue(ParameterValue parameter, Long expectedIntValue,
             String expectedStringValue, RangeValue expectedRangeValue) {
         Assert.assertEquals(expectedIntValue, parameter.getIntValue());
         Assert.assertEquals(expectedStringValue, parameter.getStringValue());
@@ -447,13 +445,15 @@ public class SecRuleEntityDecoderTest {
     @Test
     public final void testGetEtherType_ethertypeIPv4() {
         secRuleBuilder.setEthertype(EthertypeV4.class);
-        Assert.assertEquals(EtherTypeClassifierDefinition.IPv4_VALUE, SecRuleEntityDecoder.getEtherType(secRuleBuilder.build()));
+        Assert.assertEquals(EtherTypeClassifierDefinition.IPv4_VALUE,
+            SecRuleEntityDecoder.getEtherType(secRuleBuilder.build()));
     }
 
     @Test
     public final void testGetEtherType_ethertypeIPv6() {
         secRuleBuilder.setEthertype(EthertypeV6.class);
-        Assert.assertEquals(EtherTypeClassifierDefinition.IPv6_VALUE, SecRuleEntityDecoder.getEtherType(secRuleBuilder.build()));
+        Assert.assertEquals(EtherTypeClassifierDefinition.IPv6_VALUE,
+            SecRuleEntityDecoder.getEtherType(secRuleBuilder.build()));
     }
 
     @Test
@@ -476,21 +476,24 @@ public class SecRuleEntityDecoderTest {
     public final void testGetProtocol_protoTcp() {
         SecurityRuleAttributes.Protocol protocolTcp = new SecurityRuleAttributes.Protocol(ProtocolTcp.class);
         secRuleBuilder.setProtocol(protocolTcp);
-        Assert.assertEquals(IpProtoClassifierDefinition.TCP_VALUE, SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
+        Assert.assertEquals(IpProtoClassifierDefinition.TCP_VALUE,
+            SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
     }
 
     @Test
     public final void testGetProtocol_protoUdp() {
         SecurityRuleAttributes.Protocol protocolUdp = new SecurityRuleAttributes.Protocol(ProtocolUdp.class);
         secRuleBuilder.setProtocol(protocolUdp);
-        Assert.assertEquals(IpProtoClassifierDefinition.UDP_VALUE, SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
+        Assert.assertEquals(IpProtoClassifierDefinition.UDP_VALUE,
+            SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
     }
 
     @Test
     public final void testGetProtocol_protoIcmp() {
         SecurityRuleAttributes.Protocol protocolIcmp = new SecurityRuleAttributes.Protocol(ProtocolIcmp.class);
         secRuleBuilder.setProtocol(protocolIcmp);
-        Assert.assertEquals(IpProtoClassifierDefinition.ICMP_VALUE, SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
+        Assert.assertEquals(IpProtoClassifierDefinition.ICMP_VALUE,
+            SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
     }
 
     @Test
index d78fc4411a4029a0688f4a82c5fe1579c74ce735..52a43a58de965043397bb071b3a40793c57898e4 100644 (file)
@@ -75,8 +75,8 @@ public class SecRuleNameDecoderTest {
             .append(EtherTypeClassifierDefinition.DEFINITION.getName().getValue())
             .append(MappingUtils.NAME_VALUE_DELIMETER)
             .append("%s");
-        String frmtClsfName = String.format(frmtBuilder.toString(), 8010, 8020, secRule.getProtocol().getIdentityref().getSimpleName(),
-                secRule.getEthertype().getSimpleName());
+        String frmtClsfName = String.format(frmtBuilder.toString(), 8010, 8020,
+            secRule.getProtocol().getIdentityref().getSimpleName(), secRule.getEthertype().getSimpleName());
         ClassifierName expectedClsfInstanceName = new ClassifierName(frmtClsfName);
         assertEquals(expectedClsfInstanceName, SecRuleNameDecoder.getClassifierInstanceName(secRule.build()));
     }
index ae2eca73b656ffb6cdedd943524a2a436d357f22..34398017d93d793101347fa32f2b1ea301afd945 100644 (file)
@@ -81,35 +81,44 @@ public class SingleClassifierRuleTest {
 
     @Test
     public final void updateOrderBasedOnL4ClassifTest() throws Exception {
-        ParameterValue sPort = createIntParameterValue(L4ClassifierDefinition.SRC_PORT_PARAM, Long.valueOf(4999));
-        ParameterValue dPort = createIntParameterValue(L4ClassifierDefinition.DST_PORT_PARAM, Long.valueOf(8080));
-        ParameterValue sMiniRange = createRangeParameterValue(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM, 1000, 1000);
-        ParameterValue dMiniRange = createRangeParameterValue(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, 2000, 2000);
-        ParameterValue sPortRange = createRangeParameterValue(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM, 3335, 3336);
-        ParameterValue dPortRange = createRangeParameterValue(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, 9998, 9999);
-        ClassifierInstance ci;
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, dPortRange);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 180);
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, sPortRange);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 180);
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, sPort);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 170);
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, sMiniRange);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 170);
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, dPort);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 170);
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, dMiniRange);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 170);
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, sPortRange, dPortRange);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 160);
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, sPortRange, dPort);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 150);
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, sPortRange, dMiniRange);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 150);
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, dPortRange, sPort);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 150);
-        ci = createClassifierInstance(L4ClassifierDefinition.ID, dPortRange, sMiniRange);
-        assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 150);
+        final ParameterValue sourcePort = createIntParameterValue(L4ClassifierDefinition.SRC_PORT_PARAM, 4999L);
+        final ParameterValue destPort = createIntParameterValue(L4ClassifierDefinition.DST_PORT_PARAM, 8080L);
+        final ParameterValue
+            sourceMiniRange =
+            createRangeParameterValue(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM, 1000, 1000);
+        final ParameterValue
+            destinationMiniRange =
+            createRangeParameterValue(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, 2000, 2000);
+        final ParameterValue
+            sourcePortRange =
+            createRangeParameterValue(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM, 3335, 3336);
+        final ParameterValue
+            destinationPortRange =
+            createRangeParameterValue(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, 9998, 9999);
+
+        ClassifierInstance classifierInstance;
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationPortRange);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 180);
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 180);
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePort);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170);
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourceMiniRange);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170);
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destPort);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170);
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationMiniRange);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170);
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange, destinationPortRange);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 160);
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange, destPort);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150);
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange, destinationMiniRange);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150);
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationPortRange, sourcePort);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150);
+        classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationPortRange, sourceMiniRange);
+        assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150);
     }
 
     private ParameterValue createIntParameterValue(String paramName, Long value) {
index f3437756b58434bc31b5ce91e6225f134a6399a7..7647f74c07181c9dea8b32df795a4d6d142fea37 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.groupbasedpolicy.neutron.mapper.test;
 
+import com.google.common.base.Optional;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -28,8 +30,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.base.Optional;
-
 public final class ConfigDataStoreReader {
 
     private ConfigDataStoreReader() {
@@ -76,8 +76,8 @@ public final class ConfigDataStoreReader {
         }
     }
 
-    public static Optional<ConsumerNamedSelector> readConsumerNamedSelector(DataBroker dataBroker, String tenantId, String egId,
-                                                                            String selectorName) {
+    public static Optional<ConsumerNamedSelector> readConsumerNamedSelector(DataBroker dataBroker, String tenantId,
+        String egId, String selectorName) {
         InstanceIdentifier<ConsumerNamedSelector> cnsIid = IidFactory.consumerNamedSelectorIid(new TenantId(tenantId),
                 new EndpointGroupId(egId), new SelectorName(selectorName));
         try (ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction()) {
@@ -85,7 +85,8 @@ public final class ConfigDataStoreReader {
         }
     }
 
-    public static Optional<Clause> readClause(DataBroker dataBroker, String tenantId, String contractId, String clauseName) {
+    public static Optional<Clause> readClause(DataBroker dataBroker, String tenantId, String contractId,
+        String clauseName) {
         InstanceIdentifier<Clause> clauseIid = IidFactory.clauseIid(new TenantId(tenantId), new ContractId(contractId),
                 new ClauseName(clauseName));
         try (ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction()) {
index f13748b29662c49915a838aa196c723935be129c..44b1acad6e1586e8b71c5b0ee632fd995cf9924c 100644 (file)
@@ -10,12 +10,14 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.test;
 
 import static com.google.common.base.Preconditions.checkState;
 
-import javax.annotation.Nonnull;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
 import java.io.IOException;
 import java.util.Collection;
 
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
+import javax.annotation.Nonnull;
+
 import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
@@ -37,6 +39,8 @@ public abstract class CustomDataBrokerTest extends AbstractDataBrokerTest {
     }
 
     /**
+     * Used to get classes from yang modules.
+     *
      * @return a class from every yang module which needs to be loaded. Cannot return {@code null}
      *         or empty collection.
      */
index b6d564ef99dc71fe048654fe2f47a8890d89f7b4..a2d2e163ff042295b0def058e02b67cb8f665b93 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.groupbasedpolicy.neutron.mapper.test;
 
+import com.google.common.base.Strings;
+
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeBase;
@@ -17,8 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRuleBuilder;
 
-import com.google.common.base.Strings;
-
 public final class NeutronEntityFactory {
 
     private NeutronEntityFactory() {
@@ -33,8 +33,10 @@ public final class NeutronEntityFactory {
         return new SecurityGroupBuilder().setUuid(new Uuid(id)).setTenantId(new Uuid(tenantId)).setName(name).build();
     }
 
-    public static SecurityRule securityRuleWithoutGroupIds(String id, String tenant, Class<? extends EthertypeBase> etherType,
-            Class<? extends DirectionBase> direction, Class<? extends ProtocolBase> protocol, int portMin, int portMax) {
+    public static SecurityRule securityRuleWithoutGroupIds(String id, String tenant,
+        Class<? extends EthertypeBase> etherType, Class<? extends DirectionBase> direction,
+        Class<? extends ProtocolBase> protocol, int portMin, int portMax) {
+
         SecurityRuleAttributes.Protocol proto = new SecurityRuleAttributes.Protocol(protocol);
         SecurityRuleBuilder secRule = new SecurityRuleBuilder();
         secRule.setUuid(new Uuid(id));
index 865837cfd6aa819b004809089543b5010823b9cc..356027ca7cb6079259132842e9e0136e2f0275e4 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.base.Optional;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -61,6 +62,12 @@ public class NeutronMapperAssert {
         assertTrue(opt.isPresent());
     }
 
+    public static void assertNetworkDomainExists(DataBroker dataBroker, Uuid tenantUuid, Subnet subnet,
+        Neutron neutron, IpAddress ipAddress) {
+        Optional<NetworkDomain> opt = getNetworkDomainOptional(dataBroker, tenantUuid, neutron, ipAddress, subnet);
+        assertTrue(opt.isPresent());
+    }
+
     public static void assertNetworkDomainNotExists(DataBroker dataBroker, Port port, Subnet subnet,
             Neutron neutron, IpAddress ipAddress) {
         Optional<NetworkDomain> opt =
@@ -68,12 +75,6 @@ public class NeutronMapperAssert {
         assertFalse(opt.isPresent());
     }
 
-    public static void assertNetworkDomainExists(DataBroker dataBroker, Uuid tenantUuid, Subnet subnet,
-            Neutron neutron, IpAddress ipAddress) {
-        Optional<NetworkDomain> opt = getNetworkDomainOptional(dataBroker, tenantUuid, neutron, ipAddress, subnet);
-        assertTrue(opt.isPresent());
-    }
-
     public static void assertNetworkDomainNotExists(DataBroker dataBroker, Uuid tenantUuid, Subnet subnet,
             Neutron neutron, IpAddress ipAddress) {
         Optional<NetworkDomain> opt = getNetworkDomainOptional(dataBroker, tenantUuid, neutron, ipAddress, subnet);
index 14c2da9274a2bb36941b5be17c73a4e62e634231..a08a1ec74f3b86f9837b369689502c3f60364dab 100644 (file)
@@ -11,6 +11,8 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import com.google.common.collect.ImmutableList;
+
 import java.util.Collection;
 
 import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
@@ -23,8 +25,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gb
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.Tenants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
 
-import com.google.common.collect.ImmutableList;
-
 /**
  * Loads only modules of GBP and it's dependencies for data broker.
  * <br>
@@ -38,17 +38,18 @@ public class NeutronMapperDataBrokerTest extends CustomDataBrokerTest {
                 Mappings.class);
     }
 
+    @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+                                               // this will be removed when deprecated classes will be cleared.
     protected EndpointRegistrator getEpRegistrator() {
         EndpointRegistrator epRegistrator = mock(EndpointRegistrator.class);
         when(epRegistrator.registerEndpoint(any(RegisterEndpointInput.class))).thenReturn(true);
         when(epRegistrator.registerEndpoint(
-                any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput.class)))
-                    .thenReturn(true);
+            any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput.class)))
+            .thenReturn(true);
         when(epRegistrator.unregisterEndpoint(any(UnregisterEndpointInput.class))).thenReturn(true);
         when(epRegistrator.unregisterEndpoint(
-                any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput.class)))
-                    .thenReturn(true);
+            any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput.class)))
+            .thenReturn(true);
         return epRegistrator;
     }
-
 }
index 98dcc7fc1f081d9459ce272944340544fe6a3fa0..09ac059cc897069c7b57ad592206c7aa0a813d9e 100644 (file)
@@ -13,6 +13,9 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
@@ -42,9 +45,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
 public final class PolicyAssert {
 
     private PolicyAssert() {
@@ -65,7 +65,9 @@ public final class PolicyAssert {
 
     // asserts for contract
 
-    public static void assertContractExists(DataBroker dataBroker, String tenantId, String contractId) throws Exception {
+    public static void assertContractExists(DataBroker dataBroker, String tenantId, String contractId)
+        throws Exception {
+
         Optional<Contract> contract = ConfigDataStoreReader.readContract(dataBroker, tenantId, contractId);
         assertTrue(contract.isPresent());
     }
@@ -267,7 +269,8 @@ public final class PolicyAssert {
         assertEquals(SecRuleNameDecoder.getSubjectName(secRule), subjectRef);
     }
 
-    public static void assertClauseExists(DataBroker dataBroker, String tenantId, String contractId, String clauseName) {
+    public static void assertClauseExists(DataBroker dataBroker, String tenantId, String contractId,
+        String clauseName) {
         Optional<Clause> clause = ConfigDataStoreReader.readClause(dataBroker, tenantId, contractId, clauseName);
         assertTrue(clause.isPresent());
     }
@@ -297,14 +300,13 @@ public final class PolicyAssert {
         assertEquals(order, rule.getOrder().intValue());
     }
 
-    private static <T> T assertOneItem(Collection<T> c) {
-        assertNotNull(c);
-        assertTrue(c.size() == 1);
-        return c.iterator().next();
+    private static <T> T assertOneItem(Collection<T> collection) {
+        assertNotNull(collection);
+        assertTrue(collection.size() == 1);
+        return collection.iterator().next();
     }
 
     // asserts for selector
-
     public static void assertConsumerNamedSelectorExists(DataBroker dataBroker, String tenantId, String egId,
                                                          String selectorName) {
         Optional<ConsumerNamedSelector> potentialCns = ConfigDataStoreReader.readConsumerNamedSelector(dataBroker,