Another test case for .001% more coverage 66/3166/2
authorLott, Christopher (cl778h) <cl778h@att.com>
Fri, 12 Oct 2018 18:52:03 +0000 (14:52 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Fri, 12 Oct 2018 19:00:54 +0000 (15:00 -0400)
Drop unused imports.

Change-Id: I28ed2322235e96f31cec937042297ca835961e61
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
17 files changed:
gateway/src/main/java/org/acumos/federation/gateway/cds/Artifact.java
gateway/src/main/java/org/acumos/federation/gateway/cds/Mapper.java
gateway/src/main/java/org/acumos/federation/gateway/cds/PeerSubscription.java
gateway/src/main/java/org/acumos/federation/gateway/cds/Reference.java
gateway/src/main/java/org/acumos/federation/gateway/common/Clients.java
gateway/src/main/java/org/acumos/federation/gateway/common/FederationClient.java
gateway/src/main/java/org/acumos/federation/gateway/config/InterfaceConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/config/NexusConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/controller/CatalogController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/PeerSubscriptionController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/PingController.java
gateway/src/main/java/org/acumos/federation/gateway/security/FederationMethodSecurityConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/security/FederationMethodSecurityExpressionRoot.java
gateway/src/main/java/org/acumos/federation/gateway/service/PeerSubscriptionService.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/ContentServiceImpl.java
gateway/src/test/java/org/acumos/federation/gateway/test/AsdcTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/PeerGatewayTest.java

index 9909432..9cd72f9 100644 (file)
@@ -22,7 +22,6 @@ package org.acumos.federation.gateway.cds;
 import org.acumos.cds.domain.MLPArtifact;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
-
 import com.github.dockerjava.api.model.Identifier;
 
 /**
index b640b05..18f7c7c 100644 (file)
@@ -23,15 +23,14 @@ import java.io.IOException;
 
 import org.acumos.cds.domain.MLPArtifact;
 import org.acumos.cds.domain.MLPDocument;
-import org.acumos.cds.domain.MLPSolution;
-import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.cds.domain.MLPPeerSubscription;
 import org.acumos.cds.domain.MLPRevisionDescription;
+import org.acumos.cds.domain.MLPSolution;
+import org.acumos.cds.domain.MLPSolutionRevision;
 
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.Version;
-import com.fasterxml.jackson.databind.JavaType;
 import com.fasterxml.jackson.databind.DeserializationContext;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
index 36ff585..434b464 100644 (file)
@@ -21,9 +21,9 @@ package org.acumos.federation.gateway.cds;
 
 import org.acumos.cds.domain.MLPPeerSubscription;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 
 /**
  */
index dc88595..98d7a29 100644 (file)
 package org.acumos.federation.gateway.cds;
 
 import java.lang.invoke.MethodHandles;
-
 import java.net.URI;
 import java.net.URISyntaxException;
 
+import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.apache.commons.io.FilenameUtils;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-
 
 /**
  * Capable of pointing to some (external) content. Contains the content location as an uri.
index bddfadc..d8e328a 100644 (file)
@@ -30,10 +30,10 @@ import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.config.FederationInterfaceConfiguration;
 import org.acumos.federation.gateway.config.LocalInterfaceConfiguration;
 import org.acumos.federation.gateway.config.NexusConfiguration;
-import org.springframework.web.client.RestTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
 
 import com.github.dockerjava.api.DockerClient;
 
index 34ce1a5..530b130 100644 (file)
 package org.acumos.federation.gateway.common;
 
 import java.io.Closeable;
-import java.io.InputStream;
 import java.io.IOException;
-
+import java.io.InputStream;
 import java.lang.invoke.MethodHandles;
 import java.net.URI;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang.exception.ExceptionUtils;
-
 import org.acumos.cds.domain.MLPArtifact;
 import org.acumos.cds.domain.MLPDocument;
 import org.acumos.cds.domain.MLPPeer;
@@ -39,11 +36,11 @@ import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.util.Utils;
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.http.client.HttpClient;
 import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.core.io.Resource;
 import org.springframework.core.io.InputStreamResource;
-import org.springframework.util.Base64Utils;
+import org.springframework.core.io.Resource;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
@@ -52,6 +49,7 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.http.client.ClientHttpRequest;
 import org.springframework.http.client.ClientHttpResponse;
 import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.util.Base64Utils;
 import org.springframework.web.client.HttpClientErrorException;
 import org.springframework.web.client.HttpStatusCodeException;
 import org.springframework.web.client.ResourceAccessException;
index 294d6b2..2a33f9b 100644 (file)
 
 package org.acumos.federation.gateway.config;
 
-import java.lang.invoke.MethodHandles;
-
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.invoke.MethodHandles;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.security.KeyStore;
@@ -33,7 +32,6 @@ import java.security.KeyStoreException;
 import java.security.cert.X509Certificate;
 import java.util.Enumeration;
 import java.util.NoSuchElementException;
-import java.util.concurrent.TimeUnit;
 
 import javax.annotation.PostConstruct;
 import javax.net.ssl.SSLContext;
index 1ea386a..f318a42 100644 (file)
@@ -22,12 +22,12 @@ package org.acumos.federation.gateway.config;
 
 import java.lang.invoke.MethodHandles;
 
-import org.springframework.web.client.RestTemplate;
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
 import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
 
 /**
  * 
index 9ba527f..e7db988 100644 (file)
@@ -34,8 +34,8 @@ import org.acumos.cds.domain.MLPArtifact;
 import org.acumos.cds.domain.MLPDocument;
 import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
-import org.acumos.federation.gateway.cds.ArtifactType;
 import org.acumos.federation.gateway.cds.Artifact;
+import org.acumos.federation.gateway.cds.ArtifactType;
 import org.acumos.federation.gateway.cds.Document;
 import org.acumos.federation.gateway.cds.SolutionRevision;
 import org.acumos.federation.gateway.common.API;
index 99dd8f3..29dec35 100644 (file)
@@ -25,10 +25,9 @@ import java.lang.invoke.MethodHandles;
 import javax.servlet.http.HttpServletResponse;
 
 import org.acumos.cds.domain.MLPPeer;
-import org.acumos.cds.domain.MLPPeerSubscription;
+import org.acumos.federation.gateway.cds.PeerSubscription;
 import org.acumos.federation.gateway.common.API;
 import org.acumos.federation.gateway.common.JsonResponse;
-import org.acumos.federation.gateway.cds.PeerSubscription;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.service.PeerService;
 import org.acumos.federation.gateway.service.PeerSubscriptionService;
index a46763d..7def19b 100644 (file)
@@ -30,12 +30,12 @@ import org.acumos.federation.gateway.common.JsonResponse;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.service.PeerService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.security.access.prepost.PreAuthorize;
 
 import io.swagger.annotations.ApiOperation;
 
index fcea389..87805c4 100644 (file)
@@ -22,9 +22,9 @@ package org.acumos.federation.gateway.security;
 
 
 import org.springframework.context.annotation.Configuration;
+import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
 import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
 import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
-import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
 
 
 @Configuration
index ce56c30..578b982 100644 (file)
 package org.acumos.federation.gateway.security;
 
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-
-import org.springframework.security.core.Authentication;
 import org.springframework.security.access.expression.SecurityExpressionRoot;
 import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
+import org.springframework.security.core.Authentication;
 
 /**
  */
index 9e3f613..ca1d97a 100644 (file)
@@ -23,7 +23,6 @@ package org.acumos.federation.gateway.service;
 import java.util.List;
 
 import org.acumos.cds.domain.MLPPeerSubscription;
-
 import org.acumos.federation.gateway.cds.PeerSubscription;
 
 /**
index 23f3ef4..9d96ef9 100644 (file)
 package org.acumos.federation.gateway.service.impl;
 
 import java.io.InputStream;
-
+import java.lang.invoke.MethodHandles;
+import java.net.URI;
 import java.util.List;
 import java.util.stream.Stream;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import java.lang.invoke.MethodHandles;
-
 import org.acumos.cds.AccessTypeCode;
 import org.acumos.federation.gateway.cds.Artifact;
-import org.acumos.federation.gateway.cds.Document;
 import org.acumos.federation.gateway.cds.ArtifactType;
+import org.acumos.federation.gateway.cds.Document;
 import org.acumos.federation.gateway.config.DockerConfiguration;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.config.NexusConfiguration;
 import org.acumos.federation.gateway.service.ContentService;
 import org.acumos.federation.gateway.service.ServiceContext;
 import org.acumos.federation.gateway.service.ServiceException;
-
+import org.apache.commons.io.input.ProxyInputStream;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.core.io.Resource;
 import org.springframework.http.MediaType;
 import org.springframework.http.RequestEntity;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.util.UriUtils;
-import org.springframework.web.client.HttpStatusCodeException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.InputStreamResource;
 import org.springframework.stereotype.Service;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.util.UriUtils;
 
 import com.github.dockerjava.api.DockerClient;
 import com.github.dockerjava.api.model.Image;
-import com.github.dockerjava.api.model.Identifier;
-import com.github.dockerjava.api.model.Repository;
 import com.github.dockerjava.api.model.PushResponseItem;
 import com.github.dockerjava.core.command.PullImageResultCallback;
 import com.github.dockerjava.core.command.PushImageResultCallback;
 
-import org.apache.commons.io.input.ProxyInputStream;
-import org.apache.commons.compress.archivers.ArchiveStreamFactory;
-import org.apache.commons.compress.archivers.ArchiveInputStream;
-
 /**
  * Nexus based implementation of the ContentService.
  *
index 924b3a8..a98566b 100644 (file)
@@ -21,11 +21,15 @@ package org.acumos.federation.gateway.test;
 
 import java.lang.invoke.MethodHandles;
 import java.net.URI;
+import java.nio.charset.Charset;
 
 import org.acumos.federation.gateway.adapter.onap.sdc.ASDC;
+import org.acumos.federation.gateway.adapter.onap.sdc.ASDCException;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.junit.Assert;
 import org.junit.Test;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.client.HttpClientErrorException;
 
 public class AsdcTest {
 
@@ -54,4 +58,16 @@ public class AsdcTest {
                Assert.assertNotNull(asdc.getUri());
        }
 
+       @Test
+       public void testASDCException() throws Exception {
+               String responseBody = "{\"requestError\": {\"policyException\":{\"text\":\"hello\",\"variables\":[\"d\",\"e\"]}}}";
+               HttpClientErrorException ex = new HttpClientErrorException(HttpStatus.I_AM_A_TEAPOT, 
+                               "status text", responseBody.getBytes(), Charset.forName("UTF-8"));
+               ASDCException e = new ASDCException(ex);
+               e.addSuppressed(new IllegalArgumentException());
+               log.info("testASDCException: ASDC msg {}", e.getASDCMessage());
+               log.info("testASDCException: msg {}", e.getMessage());
+               log.info("testASDCException: is found? {}", ASDCException.isNotFound(new IllegalArgumentException()));
+       }
+
 }
index f21dde2..d7ccac4 100644 (file)
@@ -24,7 +24,6 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.when;
 
-import java.io.InputStream;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -39,14 +38,12 @@ import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.cds.transport.RestPageRequest;
 import org.acumos.cds.transport.RestPageResponse;
-import org.acumos.federation.gateway.cds.PeerStatus;
 import org.acumos.federation.gateway.cds.Mapper;
-import org.acumos.federation.gateway.config.CDMSClientConfiguration;
-import org.acumos.federation.gateway.config.NexusConfiguration;
+import org.acumos.federation.gateway.cds.PeerStatus;
 import org.acumos.federation.gateway.common.Clients;
 import org.acumos.federation.gateway.common.FederationClient;
-import org.acumos.nexus.client.NexusArtifactClient;
-import org.acumos.nexus.client.data.UploadArtifactInfo;
+import org.acumos.federation.gateway.config.CDMSClientConfiguration;
+import org.acumos.federation.gateway.config.NexusConfiguration;
 import org.apache.http.HttpResponse;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.client.HttpClient;
@@ -72,12 +69,12 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
 import org.springframework.boot.test.mock.mockito.MockBean;
 import org.springframework.context.ApplicationContext;
 import org.springframework.core.io.ClassPathResource;
-import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.http.RequestEntity;
-import org.springframework.web.client.RestTemplate;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.RestTemplate;
 
 
 /**