Ignore flaky ITM test
[genius.git] / itm / itm-impl / src / main / java / org / opendaylight / genius / itm / cli / VtepSchemaShow.java
index c20a2fbb8a538d6fb48f40e96879dd00d2833fc7..89ce784de878911dcc8f77deec4bebb2a7bdd082 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. 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,
@@ -8,6 +8,11 @@
 
 package org.opendaylight.genius.itm.cli;
 
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
@@ -21,12 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * The Class which implements karaf command "vtep:schema-show".
  */
@@ -38,7 +37,8 @@ public class VtepSchemaShow extends OsgiCommandSupport {
     private String schemaName;
 
     private static String VTEP_CONFIG_SCHEMA_CLI_FORMAT = "%-14s %-12s %-8s %-16s %-13s %-14s %-11s %-20s %-32s";
-    public static final String HEADER_UNDERLINE = "---------------------------------------------------------------------------------------------------------------------------------------";
+    public static final String HEADER_UNDERLINE = "------------------------------------------------------------------"
+            + "---------------------------------------------------------------------";
 
     /** The Constant logger. */
     private static final Logger LOG = LoggerFactory.getLogger(VtepSchemaShow.class);
@@ -58,9 +58,10 @@ public class VtepSchemaShow extends OsgiCommandSupport {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.apache.karaf.shell.console.AbstractAction#doExecute()
      */
+    @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
     protected Object doExecute() {
         LOG.debug("Executing command: schema-show {} ", this.schemaName);
@@ -104,7 +105,7 @@ public class VtepSchemaShow extends OsgiCommandSupport {
      *            the schema
      */
     private void printSchema(VtepConfigSchema schema) {
-        List<BigInteger> lstDpnIds = (schema.getDpnIds() == null) ? Collections.<BigInteger> emptyList()
+        List<BigInteger> lstDpnIds = (schema.getDpnIds() == null) ? Collections.emptyList()
                 : ItmUtils.getDpnIdList(schema.getDpnIds());
         List<String> lstIpFilter = getExcludeIpFilterAsList(schema.getExcludeIpFilter());
 
@@ -114,32 +115,33 @@ public class VtepSchemaShow extends OsgiCommandSupport {
         String portName = StringUtils.defaultString(schema.getPortName());
         String vlanId = String.valueOf(schema.getVlanId());
         String subnetCIDR = (schema.getSubnet() == null) ? StringUtils.EMPTY
-                : String.valueOf(schema.getSubnet().getValue());
+                : schema.getSubnet().stringValue();
         String gatewayIp = (schema.getGatewayIp() == null) ? StringUtils.EMPTY
-                : String.valueOf(schema.getGatewayIp().getValue());
+                : schema.getGatewayIp().stringValue();
         String transportZone = StringUtils.defaultString(schema.getTransportZoneName());
         String strTunnelType ;
 
         Class<? extends TunnelTypeBase> tunType = schema.getTunnelType();
 
-        if( tunType.equals(TunnelTypeGre.class) )
-            strTunnelType = ITMConstants.TUNNEL_TYPE_GRE ;
-        else
-            strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN ;
+        if (TunnelTypeGre.class.equals(tunType)) {
+            strTunnelType = ITMConstants.TUNNEL_TYPE_GRE;
+        } else {
+            strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
+        }
         String dpnId = (dpnIterator.hasNext() ? String.valueOf(dpnIterator.next()) : StringUtils.EMPTY);
         String excludeIpFilter = (ipFilterIterator.hasNext() ? String.valueOf(ipFilterIterator.next())
                 : StringUtils.EMPTY);
 
         // Print first row
-        session.getConsole().println(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, schema.getSchemaName(), portName, vlanId,
-                subnetCIDR, gatewayIp, transportZone, strTunnelType, dpnId, excludeIpFilter));
+        session.getConsole().println(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, schema.getSchemaName(),
+                portName, vlanId, subnetCIDR, gatewayIp, transportZone, strTunnelType, dpnId, excludeIpFilter));
         while (dpnIterator.hasNext() || ipFilterIterator.hasNext()) {
             dpnId = (dpnIterator.hasNext() ? String.valueOf(dpnIterator.next()) : StringUtils.EMPTY);
             excludeIpFilter = (ipFilterIterator.hasNext() ? String.valueOf(ipFilterIterator.next())
                     : StringUtils.EMPTY);
-            session.getConsole().println(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, StringUtils.EMPTY, StringUtils.EMPTY,
+            session.getConsole().println(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, StringUtils.EMPTY,
                     StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY,
-                    dpnId, excludeIpFilter));
+                    StringUtils.EMPTY, dpnId, excludeIpFilter));
         }
         session.getConsole().println(System.lineSeparator());
     }
@@ -165,11 +167,9 @@ public class VtepSchemaShow extends OsgiCommandSupport {
      * @return the vtep config schema header output
      */
     private String getHeaderOutput() {
-        StringBuilder headerBuilder = new StringBuilder();
-        headerBuilder.append(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, "SchemaName", "PortName", "VlanID", "Subnet",
-                "GatewayIP", "TransportZone", "TunnelType", "DPN-IDS", "ExcludeIpFilter"));
-        headerBuilder.append('\n');
-        headerBuilder.append(HEADER_UNDERLINE);
-        return headerBuilder.toString();
+        String headerBuilder =
+                String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, "SchemaName", "PortName", "VlanID", "Subnet", "GatewayIP",
+                        "TransportZone", "TunnelType", "DPN-IDS", "ExcludeIpFilter") + '\n' + HEADER_UNDERLINE;
+        return headerBuilder;
     }
 }