diff options
Diffstat (limited to 'pnfsimulator')
6 files changed, 65 insertions, 17 deletions
diff --git a/pnfsimulator/Dockerfile b/pnfsimulator/Dockerfile index 7cadcf4..52e507c 100644 --- a/pnfsimulator/Dockerfile +++ b/pnfsimulator/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/openjdk:8-jre-alpine +FROM docker.io/openjdk:11-jre-slim ARG VERSION=${version} diff --git a/pnfsimulator/integration/pom.xml b/pnfsimulator/integration/pom.xml index e411735..5b8e738 100644 --- a/pnfsimulator/integration/pom.xml +++ b/pnfsimulator/integration/pom.xml @@ -39,8 +39,8 @@ </repositories> <properties> - <maven.compiler.source>1.8</maven.compiler.source> - <maven.compiler.target>1.8</maven.compiler.target> + <maven.compiler.source>11</maven.compiler.source> + <maven.compiler.target>11</maven.compiler.target> </properties> <dependencies> diff --git a/pnfsimulator/pom.xml b/pnfsimulator/pom.xml index 251feb2..436571d 100644 --- a/pnfsimulator/pom.xml +++ b/pnfsimulator/pom.xml @@ -37,8 +37,8 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <maven.compiler.source>1.8</maven.compiler.source> - <maven.compiler.target>1.8</maven.compiler.target> + <maven.compiler.source>11</maven.compiler.source> + <maven.compiler.target>11</maven.compiler.target> <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format> <simulator.main.class>org.onap.pnfsimulator.Main</simulator.main.class> <docker.image.tag>latest</docker.image.tag> diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java index 3647ecc..401dc77 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java @@ -96,14 +96,14 @@ public class SimulatorController { @PostMapping("test") @Deprecated - public ResponseEntity test(@Valid @RequestBody SimulatorRequest simulatorRequest) { + public ResponseEntity<Map<String,Object>> test(@Valid @RequestBody SimulatorRequest simulatorRequest) { MDC.put("test", "test"); LOGGER.info(ENTRY, simulatorRequest.toString()); return buildResponse(OK, ImmutableMap.of(MESSAGE, "message1234")); } @PostMapping(value = "start") - public ResponseEntity start(@RequestHeader HttpHeaders headers, + public ResponseEntity<Map<String,Object>> start(@RequestHeader HttpHeaders headers, @Valid @RequestBody SimulatorRequest triggerEventRequest) { logContextHeaders(headers, "/simulator/start"); LOGGER.info(ENTRY, "Simulator started"); @@ -140,7 +140,7 @@ public class SimulatorController { @GetMapping("all-events") @Deprecated - public ResponseEntity allEvents() { + public ResponseEntity<Map<String,Object>> allEvents() { List<EventData> eventDataList = eventDataService.getAllEvents(); StringBuilder sb = new StringBuilder(); eventDataList.forEach(e -> sb.append(e).append(System.lineSeparator())); @@ -151,33 +151,33 @@ public class SimulatorController { } @GetMapping("config") - public ResponseEntity getConfig() { + public ResponseEntity<Map<String,Object>> getConfig() { SimulatorConfig configToGet = simulatorService.getConfiguration(); return buildResponse(OK, ImmutableMap.of("simulatorConfig", configToGet)); } @PutMapping("config") - public ResponseEntity updateConfig(@Valid @RequestBody SimulatorConfig newConfig) { + public ResponseEntity<Map<String,Object>> updateConfig(@Valid @RequestBody SimulatorConfig newConfig) { SimulatorConfig updatedConfig = simulatorService.updateConfiguration(newConfig); return buildResponse(OK, ImmutableMap.of("simulatorConfig", updatedConfig)); } @PostMapping("cancel/{jobName}") - public ResponseEntity cancelEvent(@PathVariable String jobName) throws SchedulerException { + public ResponseEntity<Map<String,Object>> cancelEvent(@PathVariable String jobName) throws SchedulerException { LOGGER.info(ENTRY, "Cancel called on {}.", replaceBreakingCharacters(jobName)); boolean isCancelled = simulatorService.cancelEvent(jobName); return createCancelEventResponse(isCancelled); } @PostMapping("cancel") - public ResponseEntity cancelAllEvent() throws SchedulerException { + public ResponseEntity<Map<String,Object>> cancelAllEvent() throws SchedulerException { LOGGER.info(ENTRY, "Cancel called on all jobs"); boolean isCancelled = simulatorService.cancelAllEvents(); return createCancelEventResponse(isCancelled); } @PostMapping("event") - public ResponseEntity sendEventDirectly(@RequestHeader HttpHeaders headers, @Valid @RequestBody FullEvent event) + public ResponseEntity<Map<String,Object>> sendEventDirectly(@RequestHeader HttpHeaders headers, @Valid @RequestBody FullEvent event) throws IOException, GeneralSecurityException { logContextHeaders(headers, "/simulator/event"); LOGGER.info(ENTRY, "Trying to send one-time event directly to VES Collector"); @@ -189,7 +189,7 @@ public class SimulatorController { return jobName.replaceAll(BREAKING_CHARACTER_REGEX, "_"); } - private ResponseEntity processRequest(SimulatorRequest triggerEventRequest) + private ResponseEntity<Map<String,Object>> processRequest(SimulatorRequest triggerEventRequest) throws IOException, SchedulerException, GeneralSecurityException { String jobName = simulatorService.triggerEvent(triggerEventRequest); @@ -197,7 +197,7 @@ public class SimulatorController { return buildResponse(OK, ImmutableMap.of(MESSAGE, "Request started", "jobName", jobName)); } - private ResponseEntity buildResponse(HttpStatus endStatus, Map<String, Object> parameters) { + private ResponseEntity<Map<String,Object>> buildResponse(HttpStatus endStatus, Map<String, Object> parameters) { ResponseBuilder builder = ResponseBuilder .status(endStatus) .put(TIMESTAMP, DateUtil.getTimestamp(responseDateFormat)); @@ -212,7 +212,7 @@ public class SimulatorController { MDC.put(SERVICE_NAME, serviceName); } - private ResponseEntity createCancelEventResponse(boolean isCancelled) { + private ResponseEntity<Map<String,Object>> createCancelEventResponse(boolean isCancelled) { if (isCancelled) { return buildResponse(OK, ImmutableMap.of(MESSAGE, "Event(s) was cancelled")); } else { diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/ResponseBuilder.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/ResponseBuilder.java index 5fca25a..1fdd7cf 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/ResponseBuilder.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/ResponseBuilder.java @@ -50,7 +50,7 @@ public class ResponseBuilder { return this; } - public ResponseEntity build() { + public ResponseEntity<Map<String,Object>> build() { if (body.isEmpty()) { return ResponseEntity.status(httpStatus).build(); diff --git a/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/keywords/TwoParameterKeywordTest.java b/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/keywords/TwoParameterKeywordTest.java new file mode 100644 index 0000000..6477fbf --- /dev/null +++ b/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/keywords/TwoParameterKeywordTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * Simulator + * ================================================================================ + * Copyright (C) 2020 Nokia. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.pnfsimulator.simulator.keywords; + + +import io.vavr.Tuple1; +import org.junit.jupiter.api.Test; + +import static org.junit.Assert.assertEquals; + +class TwoParameterKeywordTest { + @Test + public void whenGivenKeywordShouldReturnTwoParameterKeywordObjectWithParsedValues() { + //given + final String expectedName = "TEST"; + final Integer expectedParam1 = 123; + final Integer expectedParam2 = 456; + + String keyword = "#" + expectedName + "(" + expectedParam1 + "," + expectedParam2 + ")"; + + //when + Tuple1<TwoParameterKeyword> keywordTuple = TwoParameterKeyword.twoParameterKeyword(keyword); + TwoParameterKeyword twoParameterKeyword = keywordTuple._1(); + + //then + assertEquals(twoParameterKeyword.getName(), expectedName); + assertEquals(twoParameterKeyword.getAdditionalParameter1(), expectedParam1); + assertEquals(twoParameterKeyword.getAdditionalParameter2(), expectedParam2); + } +}
\ No newline at end of file |