summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/nbi/ServiceRegisterRunner.java6
-rw-r--r--src/main/java/org/onap/nbi/apis/status/StatusResource.java13
-rw-r--r--src/main/resources/application.properties9
-rw-r--r--src/test/java/org/onap/nbi/apis/StatusResourceTest.java11
-rw-r--r--src/test/resources/application.properties9
5 files changed, 28 insertions, 20 deletions
diff --git a/src/main/java/org/onap/nbi/ServiceRegisterRunner.java b/src/main/java/org/onap/nbi/ServiceRegisterRunner.java
index a30be98..5e0c711 100644
--- a/src/main/java/org/onap/nbi/ServiceRegisterRunner.java
+++ b/src/main/java/org/onap/nbi/ServiceRegisterRunner.java
@@ -49,16 +49,16 @@ public class ServiceRegisterRunner implements CommandLineRunner {
@Value("${msb.service.host}")
private String SERVICE_HOST;
- @Value("${msb.service.port}")
+ @Value("${server.port}")
private String SERVICE_PORT;
@Value("${msb.service.name}")
private String SERVICE_NAME;
- @Value("${msb.service.version}")
+ @Value("${nbi.version}")
private String SERVICE_VERSION;
- @Value("${msb.service.url}")
+ @Value("${server.contextPath}")
private String SERVICE_URL;
@Value("${msb.service.custom_path}")
diff --git a/src/main/java/org/onap/nbi/apis/status/StatusResource.java b/src/main/java/org/onap/nbi/apis/status/StatusResource.java
index 96332ec..4fead09 100644
--- a/src/main/java/org/onap/nbi/apis/status/StatusResource.java
+++ b/src/main/java/org/onap/nbi/apis/status/StatusResource.java
@@ -20,6 +20,7 @@ import org.onap.nbi.apis.status.model.StatusType;
import org.onap.nbi.commons.JsonRepresentation;
import org.onap.nbi.commons.ResourceManagement;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -36,8 +37,11 @@ public class StatusResource extends ResourceManagement {
@Autowired
private StatusService statusService;
+ @Value("${nbi.version}")
+ private String version;
+
private JsonRepresentation fullRepresentation = new JsonRepresentation().add("name").add("status").add("version")
- .add("components.name").add("components.status");
+ .add("components.name").add("components.status");
@GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> status(HttpServletRequest request) {
@@ -47,13 +51,12 @@ public class StatusResource extends ResourceManagement {
final String[] splitPath = request.getRequestURI().split("/");
final String applicationName = splitPath[1];
- final String applicationVersion = splitPath[3];
- final ApplicationStatus applicationStatus = this.statusService.get(applicationName, applicationVersion);
+ final ApplicationStatus applicationStatus = this.statusService.get(applicationName, version);
final boolean isServiceFullyFunctional =
- StatusType.OK.equals(applicationStatus.getStatus()) ? applicationStatus.getComponents().stream()
- .allMatch(componentStatus -> StatusType.OK.equals(componentStatus.getStatus())) : false;
+ StatusType.OK.equals(applicationStatus.getStatus()) ? applicationStatus.getComponents().stream()
+ .allMatch(componentStatus -> StatusType.OK.equals(componentStatus.getStatus())) : false;
// filter object
Object response = this.getEntity(applicationStatus, fullRepresentation);
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 347d855..c6289fa 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -14,8 +14,10 @@
# limitations under the License.
#
+nbi.version=v3
+
# SERVER
-server.contextPath=/nbi/api/v3
+server.contextPath=/nbi/api/${nbi.version}
server.port=8080
# LOGGING
@@ -27,7 +29,7 @@ onap.tenantId=6e97a2bd51d74f6db5671d8dc1517d82
onap.cloudOwner=CloudOwner
# NBI
-nbi.url=http://localhost:8080/nbi/api/v3
+nbi.url=http://localhost:${server.port}${server.contextPath}
nbi.callForVNF=false
# SCHEDULER
@@ -57,10 +59,7 @@ msb.enabled=true
msb.discovery.host=msb_discovery
msb.discovery.port=10081
msb.service.host=
-msb.service.port=${server.port}
msb.service.name=nbi
-msb.service.version=v1
-msb.service.url=${server.contextPath}
msb.service.custom_path=
msb.service.protocol=REST
msb.service.visual_range=1
diff --git a/src/test/java/org/onap/nbi/apis/StatusResourceTest.java b/src/test/java/org/onap/nbi/apis/StatusResourceTest.java
index d9309be..9b80745 100644
--- a/src/test/java/org/onap/nbi/apis/StatusResourceTest.java
+++ b/src/test/java/org/onap/nbi/apis/StatusResourceTest.java
@@ -22,6 +22,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.nbi.apis.status.StatusResource;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -37,12 +38,18 @@ public class StatusResourceTest {
@Autowired
StatusResource statusResource;
+ @Value("${server.contextPath}")
+ String contextPath;
+
+ @Value("${nbi.version}")
+ String version;
+
private MockHttpServletRequest request;
@Before
public void setup() {
request = new MockHttpServletRequest();
- request.setRequestURI("/nbi/api/v1/status");
+ request.setRequestURI(contextPath);
}
@Test
@@ -52,6 +59,6 @@ public class StatusResourceTest {
ObjectNode status = (ObjectNode) response.getBody();
assertThat(status.get("name").textValue()).isEqualTo("nbi");
assertThat(status.get("status").toString()).isEqualTo("OK");
- assertThat(status.get("version").textValue()).isEqualTo("v1");
+ assertThat(status.get("version").textValue()).isEqualTo(version);
}
}
diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties
index b214f9a..2dc0a70 100644
--- a/src/test/resources/application.properties
+++ b/src/test/resources/application.properties
@@ -14,8 +14,10 @@
# limitations under the License.
#
+nbi.version=v3
+
# SERVER
-server.contextPath=/nbi/api/v3
+server.contextPath=/nbi/api/${nbi.version}
server.port = 8080
# LOGGING
@@ -27,7 +29,7 @@ onap.tenantId=31047205ce114b60833b23e400d6a535
onap.cloudOwner=CloudOwner
# NBI
-nbi.url=http://127.0.0.1:8080/nbi/api/v3
+nbi.url=http://localhost:${server.port}${server.contextPath}
nbi.callForVNF=false
# SCHEDULER
@@ -57,10 +59,7 @@ msb.enabled=false
msb.discovery.host=msb_discovery
msb.discovery.port=10081
msb.service.host=
-msb.service.port=${server.port}
msb.service.name=nbi
-msb.service.version=v1
-msb.service.url=${server.contextPath}
msb.service.custom_path=
msb.service.protocol=REST
msb.service.visual_range=1