diff options
Diffstat (limited to 'common/src')
13 files changed, 104 insertions, 34 deletions
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java b/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java index 5b070bb00f..3b542faf7f 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java @@ -26,11 +26,12 @@ import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) @Data +@Deprecated public class AdditionalProperties implements Serializable { private static final long serialVersionUID = -4020397418955518175L; - private SliceProfile sliceProfile; + private TnSliceProfile sliceProfile; private List<EndPoint> endPoints; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java index f85cb0cd85..1b0986ca0d 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java @@ -30,7 +30,13 @@ public class AllocateTnNssi implements Serializable { private static final long serialVersionUID = -7069801712339914746L; + private TnSliceProfile sliceProfile; + private List<NetworkSliceInfo> networkSliceInfos; private List<TransportSliceNetwork> transportSliceNetworks; + + private NsiInfo nsiInfo; + + private String scriptName; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java index 1fa84eee59..3a45119195 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java @@ -32,12 +32,12 @@ public class CnSliceProfile implements Serializable { private static final long serialVersionUID = 6627071735572539536L; - @JsonProperty(value = "sNSSAIList", required = true) + @JsonProperty(value = "snssaiList", required = true) private List<String> snssaiList; private String sliceProfileId; - @JsonProperty(value = "pLMNIdList", required = true) + @JsonProperty(value = "plmnIdList", required = true) private List<String> plmnIdList; @JsonProperty(value = "perfReq", required = true) diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java b/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java index 99a8525974..3bf2ffb8eb 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java @@ -20,33 +20,15 @@ package org.onap.so.beans.nsmf; +import lombok.Data; import java.io.Serializable; - +@Data public class ConnectionLink implements Serializable { + private static final long serialVersionUID = -1834584960407180427L; private String transportEndpointA; private String transportEndpointB; - - public static long getSerialVersionUID() { - return serialVersionUID; - } - - public String getTransportEndpointA() { - return transportEndpointA; - } - - public void setTransportEndpointA(String transportEndpointA) { - this.transportEndpointA = transportEndpointA; - } - - public String getTransportEndpointB() { - return transportEndpointB; - } - - public void setTransportEndpointB(String transportEndpointB) { - this.transportEndpointB = transportEndpointB; - } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PnfErrorList.java b/common/src/main/java/org/onap/so/beans/nsmf/PnfErrorList.java index 66bfbdcea9..4fc593268a 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PnfErrorList.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PnfErrorList.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class PnfErrorList { +public class PnfErrorList implements Serializable { + + private static final long serialVersionUID = 1506455363755909867L; private String pnfId; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ResponseHistory.java b/common/src/main/java/org/onap/so/beans/nsmf/ResponseHistory.java index c71441a80a..ee027bca13 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ResponseHistory.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ResponseHistory.java @@ -21,10 +21,13 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) -public class ResponseHistory { +public class ResponseHistory implements Serializable { + + private static final long serialVersionUID = -1005342539496792450L; private int progress; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java index 9b6df0fa9e..ad6eec1c01 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java @@ -90,7 +90,7 @@ public class SliceProfileAdapter implements Serializable { } private Integer str2Code(String area) { - return area.hashCode() >> 16; + return Math.abs(area.hashCode() >> 16); } public CnSliceProfile trans2CnProfile() { @@ -100,6 +100,7 @@ public class SliceProfileAdapter implements Serializable { cnSliceProfile.setCoverageAreaTAList(Arrays.asList(this.coverageAreaTAList.split("\\|"))); cnSliceProfile.setPlmnIdList(Arrays.asList(this.pLMNIdList.split("\\|"))); cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel)); + cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(this.uEMobilityLevel)); PerfReq perfReq = new PerfReq(); // todo cnSliceProfile.setPerfReq(perfReq); diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java b/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java index aa2579edf8..c0dd4250b8 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java @@ -25,6 +25,7 @@ import java.util.List; @Data public class TransportSliceNetwork implements Serializable { + private static final long serialVersionUID = 809947462399806990L; private List<ConnectionLink> connectionLinks; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/VnfErrorList.java b/common/src/main/java/org/onap/so/beans/nsmf/VnfErrorList.java index 6388ca6106..a3330e67b4 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/VnfErrorList.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/VnfErrorList.java @@ -21,9 +21,12 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) -public class VnfErrorList { +public class VnfErrorList implements Serializable { + + private static final long serialVersionUID = -2907819676875489281L; private String vnfInstanceId; diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java index ece1333f83..9fce328b1d 100644 --- a/common/src/main/java/org/onap/so/client/RestClient.java +++ b/common/src/main/java/org/onap/so/client/RestClient.java @@ -34,10 +34,12 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; +import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation.Builder; +import javax.ws.rs.client.ResponseProcessingException; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; @@ -187,7 +189,7 @@ public abstract class RestClient { } protected Client getClient() { - return ClientBuilder.newBuilder().build(); + return ClientBuilder.newBuilder().readTimeout(props.getReadTimeout(), TimeUnit.MILLISECONDS).build(); } protected abstract ONAPComponentsList getTargetEntity(); @@ -201,7 +203,6 @@ public abstract class RestClient { metricLogClientFilter = new SOMetricLogClientFilter(); mdcSetup.setTargetEntity(getTargetEntity()); client.register(metricLogClientFilter); - if (!path.isPresent()) { webTarget = client.target(host.toString()); } else { @@ -225,6 +226,9 @@ public abstract class RestClient { result.add(e -> { return e.getCause() instanceof ConnectException; }); + result.add(e -> { + return e.getCause() instanceof ResponseProcessingException; + }); return result; } diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java index 1e8953892e..8956e20a5a 100644 --- a/common/src/main/java/org/onap/so/client/RestClientSSL.java +++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java @@ -24,6 +24,7 @@ import java.net.URI; import java.security.KeyStore; import java.security.NoSuchAlgorithmException; import java.util.Optional; +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -56,7 +57,8 @@ public abstract class RestClientSSL extends RestClient { } } // Use default SSL context - client = ClientBuilder.newBuilder().sslContext(SSLContext.getDefault()).build(); + client = ClientBuilder.newBuilder().sslContext(SSLContext.getDefault()) + .readTimeout(props.getReadTimeout(), TimeUnit.MILLISECONDS).build(); logger.info("RestClientSSL using default SSL context!"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); diff --git a/common/src/main/java/org/onap/so/client/RestProperties.java b/common/src/main/java/org/onap/so/client/RestProperties.java index 9e4e99cb4e..36da424f93 100644 --- a/common/src/main/java/org/onap/so/client/RestProperties.java +++ b/common/src/main/java/org/onap/so/client/RestProperties.java @@ -40,4 +40,13 @@ public interface RestProperties { public default boolean mapNotFoundToEmpty() { return false; } + + /** + * Time in milliseconds + * + * @return + */ + public default Long getReadTimeout() { + return Long.valueOf(60000); + } } diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java index cd00a9e4de..c6e282c14a 100644 --- a/common/src/test/java/org/onap/so/client/RestClientTest.java +++ b/common/src/test/java/org/onap/so/client/RestClientTest.java @@ -21,6 +21,8 @@ package org.onap.so.client; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.spy; @@ -28,7 +30,13 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.net.MalformedURLException; import java.net.SocketTimeoutException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Map; +import java.util.Optional; import javax.ws.rs.NotFoundException; +import javax.ws.rs.ProcessingException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilderException; @@ -37,21 +45,24 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; -import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.logging.filter.base.ONAPComponents; +import org.onap.logging.filter.base.ONAPComponentsList; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.junit.WireMockRule; @RunWith(MockitoJUnitRunner.class) public class RestClientTest { private final HttpClientFactory httpClientFactory = new HttpClientFactory(); - @Mock - private RestProperties props; @Rule public ExpectedException thrown = ExpectedException.none(); + @Rule + public WireMockRule wireMockRule = new WireMockRule(WireMockConfiguration.options().dynamicPort()); + @Test public void retries() throws Exception { RestClient spy = buildSpy(); @@ -80,6 +91,50 @@ public class RestClientTest { } + @Test + public void timeoutTest() throws URISyntaxException { + wireMockRule.stubFor(get("/chunked/delayed") + .willReturn(aResponse().withStatus(200).withBody("Hello world!").withChunkedDribbleDelay(2, 300))); + + + RestProperties props = new RestProperties() { + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(String.format("http://localhost:%s", wireMockRule.port())); + } + + @Override + public String getSystemName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Long getReadTimeout() { + return Long.valueOf(100); + } + }; + RestClient client = new RestClient(props, Optional.of(new URI("/chunked/delayed"))) { + + @Override + protected void initializeHeaderMap(Map<String, String> headerMap) { + // TODO Auto-generated method stub + + } + + @Override + protected ONAPComponentsList getTargetEntity() { + return ONAPComponents.EXTERNAL; + } + + }; + + thrown.expect(ProcessingException.class); + client.get(); + + } + private RestClient buildSpy() throws MalformedURLException, IllegalArgumentException, UriBuilderException { RestClient client = httpClientFactory.newJsonClient(UriBuilder.fromUri("http://localhost/test").build().toURL(), ONAPComponents.BPMN); |