From 947aac66eb03dc62a5f93e798325a3ad30e3c10d Mon Sep 17 00:00:00 2001 From: Bartosz Gardziejewski Date: Tue, 21 Apr 2020 09:13:14 +0200 Subject: Resolve checkstyle warnings in PNF simulator Issue-ID: INT-1517 Signed-off-by: Bartosz Gardziejewski Change-Id: I43e9f129c24ef33d93b550600e4dd850f881126b --- pnfsimulator/integration/pom.xml | 2 +- .../java/org/onap/pnfsimulator/SwaggerConfig.java | 4 +- .../main/java/org/onap/pnfsimulator/db/Row.java | 21 +- .../onap/pnfsimulator/event/EventDataService.java | 66 ++--- .../onap/pnfsimulator/logging/MDCVariables.java | 35 --- .../onap/pnfsimulator/logging/MdcVariables.java | 35 +++ .../pnfsimulator/rest/SimulatorController.java | 24 +- .../pnfsimulator/simulator/DBTemplateReader.java | 49 ---- .../pnfsimulator/simulator/DbTemplateReader.java | 51 ++++ .../simulator/EventNotFoundException.java | 9 +- .../pnfsimulator/simulator/IncrementProvider.java | 2 +- .../simulator/IncrementProviderImpl.java | 28 +- .../pnfsimulator/simulator/KeywordsExtractor.java | 69 ++--- .../pnfsimulator/simulator/SimulatorService.java | 6 +- .../pnfsimulator/simulator/TemplateReader.java | 3 +- .../simulator/client/HttpClientAdapterImpl.java | 15 +- .../client/utils/ssl/SSLAuthenticationHelper.java | 79 ------ .../client/utils/ssl/SslAuthenticationHelper.java | 79 ++++++ .../client/utils/ssl/SslSupportLevel.java | 8 +- .../pnfsimulator/simulator/keywords/Keyword.java | 8 +- .../pnfsimulator/simulator/scheduler/EventJob.java | 9 +- .../simulator/scheduler/EventScheduler.java | 6 +- .../org/onap/pnfsimulator/template/Template.java | 16 +- .../template/search/IllegalJsonValueException.java | 4 +- .../search/viewmodel/FlatTemplateContent.java | 2 +- .../template/search/viewmodel/KeyValuePair.java | 4 +- .../filesystem/InMemoryTemplateStorage.java | 62 ++--- .../pnfsimulator/rest/SimulatorControllerTest.java | 42 +-- .../pnfsimulator/rest/TemplateControllerTest.java | 4 +- .../rest/util/ResponseBuilderTest.java | 14 +- .../simulator/DBTemplateReaderTest.java | 81 ------ .../simulator/DbTemplateReaderTest.java | 81 ++++++ .../simulator/IncrementProviderImplTest.java | 59 ++--- .../KeywordsExtractorValidTimestampTest.java | 9 +- .../simulator/KeywordsHandlerTest.java | 288 +++++++++++---------- .../simulator/SimulatorServiceTest.java | 86 +++--- .../simulator/TemplatePatcherTest.java | 40 +-- .../client/HttpClientAdapterImplTest.java | 15 +- .../simulator/scheduler/EventJobTest.java | 4 +- .../simulator/scheduler/EventSchedulerTest.java | 5 +- .../pnfsimulator/template/TemplateServiceTest.java | 8 +- .../template/search/JsonUtilsTest.java | 106 ++++---- .../template/search/TemplateSearchHelperTest.java | 14 +- .../handler/PrimitiveValueCriteriaBuilderTest.java | 16 +- 44 files changed, 799 insertions(+), 769 deletions(-) delete mode 100644 pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MDCVariables.java create mode 100644 pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MdcVariables.java delete mode 100644 pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/DBTemplateReader.java create mode 100644 pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/DbTemplateReader.java delete mode 100644 pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SSLAuthenticationHelper.java create mode 100644 pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslAuthenticationHelper.java delete mode 100644 pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/DBTemplateReaderTest.java create mode 100644 pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/DbTemplateReaderTest.java (limited to 'pnfsimulator') diff --git a/pnfsimulator/integration/pom.xml b/pnfsimulator/integration/pom.xml index 2ab2dcf..e411735 100644 --- a/pnfsimulator/integration/pom.xml +++ b/pnfsimulator/integration/pom.xml @@ -25,7 +25,7 @@ 4.0.0 - org.onap.simulator + org.onap.integration.simulators.pnf-simulator integration-pnf-simulator 1.0.0-SNAPSHOT diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/SwaggerConfig.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/SwaggerConfig.java index 6e0e18e..b6c6187 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/SwaggerConfig.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/SwaggerConfig.java @@ -20,7 +20,7 @@ package org.onap.pnfsimulator; -import org.onap.pnfsimulator.simulator.client.utils.ssl.SSLAuthenticationHelper; +import org.onap.pnfsimulator.simulator.client.utils.ssl.SslAuthenticationHelper; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -31,7 +31,7 @@ import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration -@EnableConfigurationProperties(SSLAuthenticationHelper.class) +@EnableConfigurationProperties(SslAuthenticationHelper.class) @EnableSwagger2 public class SwaggerConfig { diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Row.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Row.java index f9a167b..12745bf 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Row.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Row.java @@ -7,9 +7,9 @@ * 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. @@ -20,15 +20,20 @@ package org.onap.pnfsimulator.db; +import lombok.Getter; +import lombok.Setter; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Field; public abstract class Row { - @Id - @Field("_id") - protected String id; + @Id + @Field("_id") + @Getter + @Setter + private String id; - public String getId() { - return id; - } + + public String getId() { + return id; + } } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataService.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataService.java index 3568f01..266d56b 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataService.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataService.java @@ -21,43 +21,45 @@ package org.onap.pnfsimulator.event; import com.google.gson.JsonObject; + import java.util.List; import java.util.Optional; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class EventDataService { - private final EventDataRepository repository; - - @Autowired - public EventDataService(EventDataRepository repository) { - this.repository = repository; - } - - private EventData persistEventData(String templateString, String patchedString, String inputString, String keywordsString) { - EventData eventData = EventData.builder() - .template(templateString) - .patched(patchedString) - .input(inputString) - .keywords(keywordsString) - .build(); - return repository.save(eventData); - } - - public EventData persistEventData(JsonObject templateJson, JsonObject patchedJson, JsonObject inputJson, - JsonObject keywordsJson) { - return persistEventData(templateJson.toString(), - patchedJson.toString(), - inputJson.toString(), - keywordsJson.toString()); - } - - public List getAllEvents() { - return repository.findAll(); - } - - public Optional getById(String id) { - return repository.findById(id); - } + private final EventDataRepository repository; + + @Autowired + public EventDataService(EventDataRepository repository) { + this.repository = repository; + } + + private EventData persistEventData(String templateString, String patchedString, String inputString, String keywordsString) { + EventData eventData = EventData.builder() + .template(templateString) + .patched(patchedString) + .input(inputString) + .keywords(keywordsString) + .build(); + return repository.save(eventData); + } + + public EventData persistEventData(JsonObject templateJson, JsonObject patchedJson, JsonObject inputJson, + JsonObject keywordsJson) { + return persistEventData(templateJson.toString(), + patchedJson.toString(), + inputJson.toString(), + keywordsJson.toString()); + } + + public List getAllEvents() { + return repository.findAll(); + } + + public Optional getById(String id) { + return repository.findById(id); + } } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MDCVariables.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MDCVariables.java deleted file mode 100644 index 5678f4f..0000000 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MDCVariables.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 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.logging; - -public final class MDCVariables { - - public static final String X_ONAP_REQUEST_ID = "X-ONAP-RequestID"; - public static final String X_INVOCATION_ID = "X-InvocationID"; - public static final String REQUEST_ID = "RequestID"; - public static final String INVOCATION_ID = "InvocationID"; - public static final String INSTANCE_UUID = "InstanceUUID"; - public static final String RESPONSE_CODE = "ResponseCode"; - public static final String SERVICE_NAME = "ServiceName"; - - private MDCVariables() { - } -} diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MdcVariables.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MdcVariables.java new file mode 100644 index 0000000..4feb168 --- /dev/null +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MdcVariables.java @@ -0,0 +1,35 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 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.logging; + +public final class MdcVariables { + + public static final String X_ONAP_REQUEST_ID = "X-ONAP-RequestID"; + public static final String X_INVOCATION_ID = "X-InvocationID"; + public static final String REQUEST_ID = "RequestID"; + public static final String INVOCATION_ID = "InvocationID"; + public static final String INSTANCE_UUID = "InstanceUUID"; + public static final String RESPONSE_CODE = "ResponseCode"; + public static final String SERVICE_NAME = "ServiceName"; + + private MdcVariables() { + } +} 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 0e4bd56..75a7b74 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java @@ -52,7 +52,6 @@ import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import java.io.IOException; -import java.net.MalformedURLException; import java.security.GeneralSecurityException; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -60,13 +59,13 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import static org.onap.pnfsimulator.logging.MDCVariables.INSTANCE_UUID; -import static org.onap.pnfsimulator.logging.MDCVariables.INVOCATION_ID; -import static org.onap.pnfsimulator.logging.MDCVariables.REQUEST_ID; -import static org.onap.pnfsimulator.logging.MDCVariables.RESPONSE_CODE; -import static org.onap.pnfsimulator.logging.MDCVariables.SERVICE_NAME; -import static org.onap.pnfsimulator.logging.MDCVariables.X_INVOCATION_ID; -import static org.onap.pnfsimulator.logging.MDCVariables.X_ONAP_REQUEST_ID; +import static org.onap.pnfsimulator.logging.MdcVariables.INSTANCE_UUID; +import static org.onap.pnfsimulator.logging.MdcVariables.INVOCATION_ID; +import static org.onap.pnfsimulator.logging.MdcVariables.REQUEST_ID; +import static org.onap.pnfsimulator.logging.MdcVariables.RESPONSE_CODE; +import static org.onap.pnfsimulator.logging.MdcVariables.SERVICE_NAME; +import static org.onap.pnfsimulator.logging.MdcVariables.X_INVOCATION_ID; +import static org.onap.pnfsimulator.logging.MdcVariables.X_ONAP_REQUEST_ID; import static org.onap.pnfsimulator.rest.util.ResponseBuilder.MESSAGE; import static org.onap.pnfsimulator.rest.util.ResponseBuilder.TIMESTAMP; import static org.springframework.http.HttpStatus.ACCEPTED; @@ -118,13 +117,12 @@ public class SimulatorController { return buildResponse(BAD_REQUEST, ImmutableMap.of(MESSAGE, String .format(INCORRECT_TEMPLATE_MESSAGE, triggerEventRequest.getTemplateName(), e.getMessage()))); - } catch (GeneralSecurityException e ){ - MDC.put(RESPONSE_CODE, INTERNAL_SERVER_ERROR.toString() ); + } catch (GeneralSecurityException e) { + MDC.put(RESPONSE_CODE, INTERNAL_SERVER_ERROR.toString()); LOGGER.error("Client certificate validation failed: {}", e.getMessage()); return buildResponse(INTERNAL_SERVER_ERROR, ImmutableMap.of(MESSAGE, "Invalid or misconfigured client certificate")); - } - catch (IOException e) { + } catch (IOException e) { MDC.put(RESPONSE_CODE, BAD_REQUEST.toString()); LOGGER.warn("Json validation failed: {}", e.getMessage()); return buildResponse(BAD_REQUEST, @@ -179,7 +177,7 @@ public class SimulatorController { @PostMapping("event") public ResponseEntity sendEventDirectly(@RequestHeader HttpHeaders headers, @Valid @RequestBody FullEvent event) - throws IOException, GeneralSecurityException{ + throws IOException, GeneralSecurityException { logContextHeaders(headers, "/simulator/event"); LOGGER.info(ENTRY, "Trying to send one-time event directly to VES Collector"); simulatorService.triggerOneTimeEvent(event); diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/DBTemplateReader.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/DBTemplateReader.java deleted file mode 100644 index 6c11254..0000000 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/DBTemplateReader.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 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; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import java.io.IOException; -import org.onap.pnfsimulator.template.Template; -import org.onap.pnfsimulator.template.TemplateService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class DBTemplateReader implements TemplateReader { - private final TemplateService service; - private final Gson gson; - - @Autowired - public DBTemplateReader(TemplateService service, Gson gson) { - this.service = service; - this.gson = gson; - } - - @Override - public JsonObject readTemplate(String templateName) throws IOException { - Template template = service.get(templateName).orElseThrow(() -> new IOException("Template does not exist")); - JsonElement jsonElement = gson.toJsonTree(template.getContent()); - return jsonElement.getAsJsonObject(); - } -} diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/DbTemplateReader.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/DbTemplateReader.java new file mode 100644 index 0000000..878591b --- /dev/null +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/DbTemplateReader.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Simulator + * ================================================================================ + * Copyright (C) 2019 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; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import java.io.IOException; + +import org.onap.pnfsimulator.template.Template; +import org.onap.pnfsimulator.template.TemplateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class DbTemplateReader implements TemplateReader { + private final TemplateService service; + private final Gson gson; + + @Autowired + public DbTemplateReader(TemplateService service, Gson gson) { + this.service = service; + this.gson = gson; + } + + @Override + public JsonObject readTemplate(String templateName) throws IOException { + Template template = service.get(templateName).orElseThrow(() -> new IOException("Template does not exist")); + JsonElement jsonElement = gson.toJsonTree(template.getContent()); + return jsonElement.getAsJsonObject(); + } +} diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/EventNotFoundException.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/EventNotFoundException.java index 4f43d8c..01f6508 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/EventNotFoundException.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/EventNotFoundException.java @@ -21,8 +21,9 @@ package org.onap.pnfsimulator.simulator; public class EventNotFoundException extends RuntimeException { - private static final String NOT_FOUND = "Not found an event with id: "; - public EventNotFoundException(String eventId) { - super(NOT_FOUND + eventId); - } + private static final String NOT_FOUND = "Not found an event with id: "; + + public EventNotFoundException(String eventId) { + super(NOT_FOUND + eventId); + } } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/IncrementProvider.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/IncrementProvider.java index ea87ae6..4a7cf02 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/IncrementProvider.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/IncrementProvider.java @@ -22,5 +22,5 @@ package org.onap.pnfsimulator.simulator; @FunctionalInterface public interface IncrementProvider { - int getAndIncrement(String id); + int getAndIncrement(String id); } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/IncrementProviderImpl.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/IncrementProviderImpl.java index 16c0a0e..9d4d3ec 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/IncrementProviderImpl.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/IncrementProviderImpl.java @@ -27,21 +27,21 @@ import org.springframework.stereotype.Service; @Service public class IncrementProviderImpl implements IncrementProvider { - private final EventDataRepository repository; + private final EventDataRepository repository; - @Autowired - public IncrementProviderImpl(EventDataRepository repository) { - this.repository = repository; - } + @Autowired + public IncrementProviderImpl(EventDataRepository repository) { + this.repository = repository; + } - @Override - public int getAndIncrement(String id) { - EventData eventData = repository.findById(id) - .orElseThrow(() -> new EventNotFoundException(id)); - int value = eventData.getIncrementValue() + 1; - eventData.setIncrementValue(value); - repository.save(eventData); - return value; - } + @Override + public int getAndIncrement(String id) { + EventData eventData = repository.findById(id) + .orElseThrow(() -> new EventNotFoundException(id)); + int value = eventData.getIncrementValue() + 1; + eventData.setIncrementValue(value); + repository.save(eventData); + return value; + } } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/KeywordsExtractor.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/KeywordsExtractor.java index 23c383f..2dc52a1 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/KeywordsExtractor.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/KeywordsExtractor.java @@ -32,6 +32,7 @@ import static org.onap.pnfsimulator.simulator.KeywordsValueProvider.getTimestamp import static org.onap.pnfsimulator.simulator.keywords.NonParameterKeywordPatterns.$nonParameterKeyword; import static org.onap.pnfsimulator.simulator.keywords.SingleParameterKeywordPatterns.$singleParameterKeyword; import static org.onap.pnfsimulator.simulator.keywords.TwoParameterKeywordPatterns.$twoParameterKeyword; + import io.vavr.API.Match.Pattern1; import org.onap.pnfsimulator.simulator.keywords.Keyword; import org.onap.pnfsimulator.simulator.keywords.NonParameterKeyword; @@ -44,43 +45,53 @@ public class KeywordsExtractor { String substituteStringKeyword(String text, int increment) { return Match(text).of( - Case(isRandomStringParamKeyword(), - spk -> spk.substituteKeyword(getRandomString().apply(spk.getAdditionalParameter()))), - Case(isRandomStringNonParamKeyword(), - npk -> npk.substituteKeyword(getRandomLimitedString().apply())), - Case(isRandomIntegerParamKeyword(), - tpk -> tpk.substituteKeyword(getRandomInteger().apply(tpk.getAdditionalParameter1(), tpk.getAdditionalParameter2()))), - Case(isRandomIntegerNonParamKeyword(), - npk -> npk.substituteKeyword(getRandomLimitedInteger().apply())), - Case(isIncrementKeyword(), - ik -> ik.substituteKeyword(String.valueOf(increment))), - Case(isTimestampNonParamKeyword(), - npk -> npk.substituteKeyword(getEpochSecond().apply())), - Case( - $(), - () -> text - )); + Case(isRandomStringParamKeyword(), + spk -> spk.substituteKeyword(getRandomString().apply(spk.getAdditionalParameter())) + ), + Case(isRandomStringNonParamKeyword(), + npk -> npk.substituteKeyword(getRandomLimitedString().apply()) + ), + Case(isRandomIntegerParamKeyword(), + tpk -> tpk.substituteKeyword(getRandomInteger().apply( + tpk.getAdditionalParameter1(), + tpk.getAdditionalParameter2() + ) + ) + ), + Case(isRandomIntegerNonParamKeyword(), + npk -> npk.substituteKeyword(getRandomLimitedInteger().apply()) + ), + Case(isIncrementKeyword(), + ik -> ik.substituteKeyword(String.valueOf(increment)) + ), + Case(isTimestampNonParamKeyword(), + npk -> npk.substituteKeyword(getEpochSecond().apply()) + ), + Case( + $(), + () -> text + )); } Long substitutePrimitiveKeyword(String text) { return Match(text).of( - Case(isRandomPrimitiveIntegerParamKeyword(), - tpk -> - getRandomPrimitiveInteger().apply(tpk.getAdditionalParameter1(), tpk.getAdditionalParameter2())), - Case(isTimestampPrimitiveNonParamKeyword(), - tpk -> - getTimestampPrimitive().apply()), - Case( - $(), - () -> 0L - )); + Case(isRandomPrimitiveIntegerParamKeyword(), + tpk -> + getRandomPrimitiveInteger().apply(tpk.getAdditionalParameter1(), tpk.getAdditionalParameter2())), + Case(isTimestampPrimitiveNonParamKeyword(), + tpk -> + getTimestampPrimitive().apply()), + Case( + $(), + () -> 0L + )); } boolean isPrimitive(String text) { return Match(text).of( - Case(isRandomPrimitiveIntegerParamKeyword(), () -> true), - Case(isTimestampPrimitiveNonParamKeyword(), () -> true), - Case($(), () -> false)); + Case(isRandomPrimitiveIntegerParamKeyword(), () -> true), + Case(isTimestampPrimitiveNonParamKeyword(), () -> true), + Case($(), () -> false)); } private Pattern1 isRandomStringParamKeyword() { diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorService.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorService.java index ca00696..02f50e4 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorService.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorService.java @@ -29,7 +29,7 @@ import org.onap.pnfsimulator.rest.model.SimulatorParams; import org.onap.pnfsimulator.rest.model.SimulatorRequest; import org.onap.pnfsimulator.simulator.client.HttpClientAdapter; import org.onap.pnfsimulator.simulator.client.HttpClientAdapterImpl; -import org.onap.pnfsimulator.simulator.client.utils.ssl.SSLAuthenticationHelper; +import org.onap.pnfsimulator.simulator.client.utils.ssl.SslAuthenticationHelper; import org.onap.pnfsimulator.simulator.scheduler.EventScheduler; import org.onap.pnfsimulator.simulatorconfig.SimulatorConfig; import org.onap.pnfsimulator.simulatorconfig.SimulatorConfigService; @@ -48,14 +48,14 @@ public class SimulatorService { private final TemplateReader templateReader; private final EventDataService eventDataService; private final EventScheduler eventScheduler; - private final SSLAuthenticationHelper sslAuthenticationHelper; + private final SslAuthenticationHelper sslAuthenticationHelper; private SimulatorConfigService simulatorConfigService; private static final JsonObject EMPTY_JSON_OBJECT = new JsonObject(); @Autowired public SimulatorService(TemplatePatcher templatePatcher, TemplateReader templateReader, EventScheduler eventScheduler, EventDataService eventDataService, - SimulatorConfigService simulatorConfigService, SSLAuthenticationHelper sslAuthenticationHelper) { + SimulatorConfigService simulatorConfigService, SslAuthenticationHelper sslAuthenticationHelper) { this.templatePatcher = templatePatcher; this.templateReader = templateReader; this.eventDataService = eventDataService; diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/TemplateReader.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/TemplateReader.java index bf06381..2471c08 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/TemplateReader.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/TemplateReader.java @@ -21,8 +21,9 @@ package org.onap.pnfsimulator.simulator; import com.google.gson.JsonObject; + import java.io.IOException; public interface TemplateReader { - JsonObject readTemplate(String templateName) throws IOException; + JsonObject readTemplate(String templateName) throws IOException; } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImpl.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImpl.java index 0291878..7ddef86 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImpl.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImpl.java @@ -26,7 +26,7 @@ import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.util.EntityUtils; -import org.onap.pnfsimulator.simulator.client.utils.ssl.SSLAuthenticationHelper; +import org.onap.pnfsimulator.simulator.client.utils.ssl.SslAuthenticationHelper; import org.onap.pnfsimulator.simulator.client.utils.ssl.SslSupportLevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,9 +39,9 @@ import java.io.UnsupportedEncodingException; import java.security.GeneralSecurityException; import java.util.UUID; -import static org.onap.pnfsimulator.logging.MDCVariables.REQUEST_ID; -import static org.onap.pnfsimulator.logging.MDCVariables.X_INVOCATION_ID; -import static org.onap.pnfsimulator.logging.MDCVariables.X_ONAP_REQUEST_ID; +import static org.onap.pnfsimulator.logging.MdcVariables.REQUEST_ID; +import static org.onap.pnfsimulator.logging.MdcVariables.X_INVOCATION_ID; +import static org.onap.pnfsimulator.logging.MdcVariables.X_ONAP_REQUEST_ID; public class HttpClientAdapterImpl implements HttpClientAdapter { @@ -59,10 +59,11 @@ public class HttpClientAdapterImpl implements HttpClientAdapter { private HttpClient client; private final String targetUrl; - public HttpClientAdapterImpl(String targetUrl, SSLAuthenticationHelper sslAuthenticationHelper) + public HttpClientAdapterImpl(String targetUrl, SslAuthenticationHelper sslAuthenticationHelper) throws IOException, GeneralSecurityException { - this.sslSupportLevel = sslAuthenticationHelper.isClientCertificateEnabled() ? - SslSupportLevel.CLIENT_CERT_AUTH : SslSupportLevel.getSupportLevelBasedOnProtocol(targetUrl); + this.sslSupportLevel = sslAuthenticationHelper.isClientCertificateEnabled() + ? SslSupportLevel.CLIENT_CERT_AUTH + : SslSupportLevel.getSupportLevelBasedOnProtocol(targetUrl); this.client = sslSupportLevel.getClient(CONFIG, sslAuthenticationHelper); this.targetUrl = targetUrl; } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SSLAuthenticationHelper.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SSLAuthenticationHelper.java deleted file mode 100644 index eda17ef..0000000 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SSLAuthenticationHelper.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2019 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.client.utils.ssl; - -import java.io.Serializable; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - -@Component -@ConfigurationProperties(prefix = "ssl") -@RefreshScope -@Primary -public class SSLAuthenticationHelper implements Serializable { - - private boolean clientCertificateEnabled; - private String clientCertificateDir; - private String clientCertificatePassword; - private String trustStoreDir; - private String trustStorePassword; - - public boolean isClientCertificateEnabled() { - return clientCertificateEnabled; - } - - public void setClientCertificateEnabled(boolean clientCertificateEnabled) { - this.clientCertificateEnabled = clientCertificateEnabled; - } - - public String getClientCertificateDir() { - return clientCertificateDir; - } - - public void setClientCertificateDir(String clientCertificateDir) { - this.clientCertificateDir = clientCertificateDir; - } - - public String getClientCertificatePassword() { - return clientCertificatePassword; - } - - public void setClientCertificatePassword(String clientCertificatePassword) { - this.clientCertificatePassword = clientCertificatePassword; - } - - public String getTrustStoreDir() { - return trustStoreDir; - } - - public void setTrustStoreDir(String trustStoreDir) { - this.trustStoreDir = trustStoreDir; - } - - public String getTrustStorePassword() { - return trustStorePassword; - } - - public void setTrustStorePassword(String trustStorePassword) { - this.trustStorePassword = trustStorePassword; - } -} diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslAuthenticationHelper.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslAuthenticationHelper.java new file mode 100644 index 0000000..ee5fdb7 --- /dev/null +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslAuthenticationHelper.java @@ -0,0 +1,79 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2019 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.client.utils.ssl; + +import java.io.Serializable; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "ssl") +@RefreshScope +@Primary +public class SslAuthenticationHelper implements Serializable { + + private boolean clientCertificateEnabled; + private String clientCertificateDir; + private String clientCertificatePassword; + private String trustStoreDir; + private String trustStorePassword; + + public boolean isClientCertificateEnabled() { + return clientCertificateEnabled; + } + + public void setClientCertificateEnabled(boolean clientCertificateEnabled) { + this.clientCertificateEnabled = clientCertificateEnabled; + } + + public String getClientCertificateDir() { + return clientCertificateDir; + } + + public void setClientCertificateDir(String clientCertificateDir) { + this.clientCertificateDir = clientCertificateDir; + } + + public String getClientCertificatePassword() { + return clientCertificatePassword; + } + + public void setClientCertificatePassword(String clientCertificatePassword) { + this.clientCertificatePassword = clientCertificatePassword; + } + + public String getTrustStoreDir() { + return trustStoreDir; + } + + public void setTrustStoreDir(String trustStoreDir) { + this.trustStoreDir = trustStoreDir; + } + + public String getTrustStorePassword() { + return trustStorePassword; + } + + public void setTrustStorePassword(String trustStorePassword) { + this.trustStorePassword = trustStorePassword; + } +} diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslSupportLevel.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslSupportLevel.java index c05f4c6..393a6c5 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslSupportLevel.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslSupportLevel.java @@ -46,7 +46,7 @@ import java.util.Optional; public enum SslSupportLevel { NONE { - public HttpClient getClient(RequestConfig requestConfig, SSLAuthenticationHelper sslAuthenticationHelper) { + public HttpClient getClient(RequestConfig requestConfig, SslAuthenticationHelper sslAuthenticationHelper) { LOGGER.info(""); return HttpClientBuilder .create() @@ -55,7 +55,7 @@ public enum SslSupportLevel { } }, ALWAYS_TRUST { - public HttpClient getClient(RequestConfig requestConfig, SSLAuthenticationHelper sslAuthenticationHelper) + public HttpClient getClient(RequestConfig requestConfig, SslAuthenticationHelper sslAuthenticationHelper) throws GeneralSecurityException, IOException { LoggerFactory.getLogger(SslSupportLevel.class).info(""); HttpClient client; @@ -76,7 +76,7 @@ public enum SslSupportLevel { }, CLIENT_CERT_AUTH { @Override - public HttpClient getClient(RequestConfig requestConfig, SSLAuthenticationHelper sslAuthenticationHelper) + public HttpClient getClient(RequestConfig requestConfig, SslAuthenticationHelper sslAuthenticationHelper) throws GeneralSecurityException, IOException { SSLContext sslContext = SSLContexts.custom() @@ -111,7 +111,7 @@ public enum SslSupportLevel { return "https".equals(new URL(url).getProtocol()) ? SslSupportLevel.ALWAYS_TRUST : SslSupportLevel.NONE; } - public abstract HttpClient getClient(RequestConfig config, SSLAuthenticationHelper sslAuthenticationHelper) + public abstract HttpClient getClient(RequestConfig config, SslAuthenticationHelper sslAuthenticationHelper) throws GeneralSecurityException, IOException; } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/keywords/Keyword.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/keywords/Keyword.java index b7f6fb3..1bb1332 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/keywords/Keyword.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/keywords/Keyword.java @@ -36,13 +36,13 @@ public class Keyword { protected static final String NONLETTERS_REGEX = "([^a-zA-Z]+)"; protected static final Function1 OPTIONAL = - regex -> regex + "?"; + regex -> regex + "?"; private final String name; private final List meaningfulParts; public static final Function2 IS_MATCHING_KEYWORD_NAME = (keyword, key) -> - keyword != null && keyword.getName() != null && keyword.getName().equals(key); + keyword != null && keyword.getName() != null && keyword.getName().equals(key); /** * Returns list of independent parts inside the keyword. Current implementation assumes that customer can join keywords with integer values, so @@ -69,8 +69,8 @@ public class Keyword { public String substituteKeyword(String substitution) { return meaningfulParts.stream() - .map(part -> part.equals(name) ? substitution : part) - .collect(Collectors.joining()); + .map(part -> part.equals(name) ? substitution : part) + .collect(Collectors.joining()); } } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/EventJob.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/EventJob.java index 6e4411d..21e0466 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/EventJob.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/EventJob.java @@ -25,7 +25,7 @@ import com.google.gson.JsonObject; import org.onap.pnfsimulator.simulator.KeywordsHandler; import org.onap.pnfsimulator.simulator.client.HttpClientAdapter; import org.onap.pnfsimulator.simulator.client.HttpClientAdapterImpl; -import org.onap.pnfsimulator.simulator.client.utils.ssl.SSLAuthenticationHelper; +import org.onap.pnfsimulator.simulator.client.utils.ssl.SslAuthenticationHelper; import org.quartz.Job; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; @@ -73,8 +73,11 @@ public class EventJob implements Job { private Optional getHttpClientAdapter(JobDataMap jobDataMap, String vesUrl) { HttpClientAdapter adapter = null; try { - adapter = (HttpClientAdapter) (jobDataMap.containsKey(CLIENT_ADAPTER) ? jobDataMap.get(CLIENT_ADAPTER) : - new HttpClientAdapterImpl(vesUrl, new SSLAuthenticationHelper())); + adapter = (HttpClientAdapter) ( + jobDataMap.containsKey(CLIENT_ADAPTER) + ? jobDataMap.get(CLIENT_ADAPTER) + : new HttpClientAdapterImpl(vesUrl, new SslAuthenticationHelper()) + ); } catch (MalformedURLException e) { LOGGER.error("Invalid format of vesServerUr: {}", vesUrl); } catch (IOException | GeneralSecurityException e) { diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/EventScheduler.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/EventScheduler.java index bd2c577..5584cb1 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/EventScheduler.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/EventScheduler.java @@ -23,7 +23,7 @@ package org.onap.pnfsimulator.simulator.scheduler; import com.google.gson.JsonObject; import org.onap.pnfsimulator.simulator.KeywordsHandler; import org.onap.pnfsimulator.simulator.client.HttpClientAdapterImpl; -import org.onap.pnfsimulator.simulator.client.utils.ssl.SSLAuthenticationHelper; +import org.onap.pnfsimulator.simulator.client.utils.ssl.SslAuthenticationHelper; import org.quartz.JobBuilder; import org.quartz.JobDataMap; import org.quartz.JobDetail; @@ -56,10 +56,10 @@ public class EventScheduler { private final Scheduler scheduler; private final KeywordsHandler keywordsHandler; - private final SSLAuthenticationHelper sslAuthenticationHelper; + private final SslAuthenticationHelper sslAuthenticationHelper; @Autowired - public EventScheduler(Scheduler scheduler, KeywordsHandler keywordsHandler, SSLAuthenticationHelper sslAuthenticationHelper) { + public EventScheduler(Scheduler scheduler, KeywordsHandler keywordsHandler, SslAuthenticationHelper sslAuthenticationHelper) { this.scheduler = scheduler; this.keywordsHandler = keywordsHandler; this.sslAuthenticationHelper = sslAuthenticationHelper; diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/Template.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/Template.java index c84b8d0..121d7d4 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/Template.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/Template.java @@ -44,14 +44,14 @@ public class Template extends Row { private long lmod; public Template(String name, Document content, long lmod) { - this.id = name; + this.setId(name); this.content = content; this.lmod = lmod; this.flatContent = new JsonUtils().flatten(content); } public Template(String name, String template, long lmod) { - this.id = name; + this.setId(name); this.content = Document.parse(template); this.lmod = lmod; this.flatContent = new JsonUtils().flatten(this.content); @@ -72,21 +72,21 @@ public class Template extends Row { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object object) { + if (this == object) { return true; } - if (o == null || getClass() != o.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - Template template = (Template) o; + Template template = (Template) object; return Objects.equals(content, template.content) - && Objects.equals(id, template.id) + && Objects.equals(getId(), template.getId()) && Objects.equals(lmod, template.lmod); } @Override public int hashCode() { - return Objects.hash(content, id); + return Objects.hash(content, getId()); } } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/IllegalJsonValueException.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/IllegalJsonValueException.java index 6890382..1685536 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/IllegalJsonValueException.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/IllegalJsonValueException.java @@ -22,7 +22,7 @@ package org.onap.pnfsimulator.template.search; public class IllegalJsonValueException extends IllegalArgumentException { - IllegalJsonValueException(String s) { - super(s); + IllegalJsonValueException(String message) { + super(message); } } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/viewmodel/FlatTemplateContent.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/viewmodel/FlatTemplateContent.java index 84235f7..8634052 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/viewmodel/FlatTemplateContent.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/viewmodel/FlatTemplateContent.java @@ -37,7 +37,7 @@ public class FlatTemplateContent extends Row { public FlatTemplateContent(String name, List keyValues) { - this.id = name; + this.setId(name); this.keyValues = keyValues; } } diff --git a/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/viewmodel/KeyValuePair.java b/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/viewmodel/KeyValuePair.java index 5e44452..8f24334 100644 --- a/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/viewmodel/KeyValuePair.java +++ b/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/viewmodel/KeyValuePair.java @@ -34,7 +34,7 @@ import lombok.ToString; */ public class KeyValuePair { - private String k; - private String v; + private String key; + private String value; } diff --git a/pnfsimulator/src/test/java/org/onap/pnfsimulator/filesystem/InMemoryTemplateStorage.java b/pnfsimulator/src/test/java/org/onap/pnfsimulator/filesystem/InMemoryTemplateStorage.java index 98c4bc5..b86a0f9 100644 --- a/pnfsimulator/src/test/java/org/onap/pnfsimulator/filesystem/InMemoryTemplateStorage.java +++ b/pnfsimulator/src/test/java/org/onap/pnfsimulator/filesystem/InMemoryTemplateStorage.java @@ -7,9 +7,9 @@ * 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. @@ -30,42 +30,42 @@ import org.onap.pnfsimulator.template.Template; public class InMemoryTemplateStorage implements Storage