Enable maven-checkstyle-plugin in apex-pdp/pom.xml to fail the build at warning level.
Fix all the existing check style issues in the component.
Change-Id: I4de9c1bd9ca5a2876de9086d2d3526cbdc25c080
Issue-ID: POLICY-1732
Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.client.editor.rest.handling;
import java.util.Map.Entry;
-
import org.onap.policy.apex.client.editor.rest.handling.bean.BeanEvent;
import org.onap.policy.apex.client.editor.rest.handling.bean.BeanField;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
/**
* Create the parameters on an event.
- *
+ *
* @param session the Apex editor session
* @param jsonbean the JSON bean holding the parameters
- * @param result the result of the parameter creation operation
- * @return
+ * @return result the result of the parameter creation operation
*/
private ApexApiResult createEventParameters(final RestSession session, final BeanEvent jsonbean) {
ApexApiResult result = new ApexApiResult();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
-
import java.util.ArrayList;
import java.util.List;
-
import org.onap.policy.apex.client.editor.rest.handling.bean.BeanModel;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
/**
* Augment a message with key information.
- *
+ *
* @param session the Apex model editing session
* @param message The message to augment
* @return the augmented message
/**
* Get an embedded JSON object for the given JSON object.
- *
+ *
* @param jsonObject the input JSON object
* @return the embedded JSON object
*/
/**
* Condition a field so its key information can be looked up.
- *
+ *
* @param jsonObject the object to query
* @param fieldTag the tag of the field to condition
* @param fieldValue the value of the field to condition
- * @return
+ * @return field read from the json
*/
private String readFieldFromJsonObject(final JsonObject jsonObject, final String fieldTag, final String value) {
String lookedupValue = value;
/**
* Look up the UUID and description in the key information for a concept.
- *
+ *
* @param session the Apex editor session
* @param jsonObject the JSON object to place the fields in
* @param name the concept name to look up
/**
* Look up the key information for the given concept name and value.
- *
+ *
* @param session the Apex editor session
* @param name the concept name to look up
* @param version the concept version to look up
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
/**
* Handle and return the response to the engine status message.
- *
+ *
* @param message the incoming status message
* @param successFlag true if the result should be successful
- * @return
+ * @return engine status success or not
*/
private boolean handleAndReturnEngineStatus(Message message, boolean successFlag) {
if ("DoNotRespond".equals(message.getTarget().getName())) {
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* task logic, task selection logic, and state finalizer logic respectively when that logic is
* executing in an executor plugin under the control of an APEX engine.
*
- * The AxStateFacade and AxTaskFacade classes provide facades and convenience
+ * <p>The AxStateFacade and AxTaskFacade classes provide facades and convenience
* methods for state and task definition information for logic at execution time.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.apex.core.infrastructure.messaging.impl.ws;
import com.google.common.eventbus.Subscribe;
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
-
import org.onap.policy.apex.core.infrastructure.messaging.MessageHolder;
import org.onap.policy.apex.core.infrastructure.messaging.MessageListener;
import org.onap.policy.apex.core.infrastructure.messaging.impl.ws.messageblock.MessageBlock;
// processing thread
try (final ByteArrayInputStream stream = new ByteArrayInputStream(dataByteBuffer.array());
- final ObjectInputStream ois = new ObjectInputStream(stream);) {
+ final ObjectInputStream ois = new ObjectInputStream(stream)) {
@SuppressWarnings("unchecked")
final MessageHolder<M> messageHolder = (MessageHolder<M>) ois.readObject();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Huawei. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
+import java.security.cert.X509Certificate;
import java.util.Base64;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
-import java.security.cert.X509Certificate;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 huawei. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.apex.examples.bbs;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import javax.net.ssl.HttpsURLConnection;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
public class WebClientTest {
- HttpsURLConnection mockedHttpsURLConnection;
+ HttpsURLConnection mockedHttpsUrlConnection;
String sampleString = "Response Code :200";
/**
* Set up the mocked REST manager.
+ * @throws IOException
*/
@Before
- public void setupMockedRest() {
- mockedHttpsURLConnection = mock(HttpsURLConnection.class);
- InputStream iStream = new ByteArrayInputStream(sampleString.getBytes());
- try {
- when(mockedHttpsURLConnection.getInputStream()).thenReturn(iStream);
- Mockito.doNothing().when(mockedHttpsURLConnection).connect();
- }catch (Exception e) {
- }
-
+ public void setupMockedRest() throws IOException {
+ mockedHttpsUrlConnection = mock(HttpsURLConnection.class);
+ InputStream inputStream = new ByteArrayInputStream(sampleString.getBytes());
+ when(mockedHttpsUrlConnection.getInputStream()).thenReturn(inputStream);
+ Mockito.doNothing().when(mockedHttpsUrlConnection).connect();
}
@Test
@Test
public void toPrettyString() {
- String xmlSample = "<input xmlns=\"org:onap:sdnc:northbound:generic-resource\">" +
- "<sdnc-request-header> <svc-action>update</svc-action> </sdnc-request-header></input>";
+ String xmlSample = "<input xmlns=\"org:onap:sdnc:northbound:generic-resource\">"
+ + "<sdnc-request-header> <svc-action>update</svc-action> </sdnc-request-header></input>";
WebClient cl = new WebClient();
cl.toPrettyString(xmlSample, 4);
}
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
* Provides the base definition of an APEX model. It also defines the Model Service, the mechanism that allows access to
* the model for APEX concepts anywhere in the system.
*
- * It also provides handling support to models, allowing them to be read and written to file and databases in JSON and
- * XML format.
- *
+ * <p>It also provides handling support to models, allowing them to be read and written to file and databases in JSON
+ * and XML format.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
package org.onap.policy.apex.model.basicmodel;
package org.onap.policy.apex.model.contextmodel.concepts;
import java.util.List;
-
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@AttributeOverrides({
@AttributeOverride(name = "name", column = @Column(name = "itemSchemaName")),
@AttributeOverride(name = "version", column = @Column(name = "itemSchemaVersion"))
- })
+ })
@Column(name = "itemSchema")
@XmlElement(name = "itemSchema", required = true)
private AxArtifactKey itemSchema;
package org.onap.policy.apex.model.contextmodel.concepts;
import java.util.List;
-
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@JoinColumns({
@JoinColumn(name = "schemasName", referencedColumnName = "name"),
@JoinColumn(name = "schemasVersion", referencedColumnName = "version")
- })
+ })
@XmlElement(name = "schemas", required = true)
private AxContextSchemas schemas;
@JoinColumns({
@JoinColumn(name = "albumsName", referencedColumnName = "name"),
@JoinColumn(name = "albumsVersion", referencedColumnName = "version")
- })
+ })
@XmlElement(name = "albums", required = true)
private AxContextAlbums albums;
// @formatter:on
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Base64;
import java.util.Properties;
-
import javax.naming.Context;
-
+import org.apache.commons.lang3.StringUtils;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for JMS as an event carrier technology.
- *
+ *
* <p>The parameters for this plugin are:
* <ol>
* <li>initialContextFactory: JMS uses a naming {@link Context} object to look up the locations of JMS servers and JMS
public GroupValidationResult validate() {
final GroupValidationResult result = super.validate();
- if (isNullOrBlank(initialContextFactory)) {
+ if (StringUtils.isBlank(initialContextFactory)) {
result.setResult("initialContextFactory", ValidationStatus.INVALID,
"initialContextFactory must be specified as a string that is a class that implements the "
+ "interface org.jboss.naming.remote.client.InitialContextFactory");
}
- if (isNullOrBlank(providerUrl)) {
+ if (StringUtils.isBlank(providerUrl)) {
result.setResult("providerUrl", ValidationStatus.INVALID,
"providerUrl must be specified as a URL string that specifies the location of "
+ "configuration information for the service provider to use "
+ "such as remote://localhost:4447");
}
- if (isNullOrBlank(securityPrincipal)) {
+ if (StringUtils.isBlank(securityPrincipal)) {
result.setResult("securityPrincipal", ValidationStatus.INVALID,
"securityPrincipal must be specified the identity of the principal for authenticating "
+ "the caller to the service");
}
- if (isNullOrBlank(securityCredentials)) {
+ if (StringUtils.isBlank(securityCredentials)) {
result.setResult("securityCredentials", ValidationStatus.INVALID,
" securityCredentials must be specified as the credentials of the "
+ "principal for authenticating the caller to the service");
}
- if (isNullOrBlank(producerTopic)) {
+ if (StringUtils.isBlank(producerTopic)) {
result.setResult("producerTopic", ValidationStatus.INVALID,
" producerTopic must be a string that identifies the JMS topic "
+ "on which Apex will send events");
}
- if (isNullOrBlank(consumerTopic)) {
+ if (StringUtils.isBlank(consumerTopic)) {
result.setResult("consumerTopic", ValidationStatus.INVALID,
" consumerTopic must be a string that identifies the JMS topic "
+ "on which Apex will recieve events");
return result;
}
- /**
- * Check if the string is null or blank.
- *
- * @param stringValue the string value
- * @return
- */
- private boolean isNullOrBlank(final String stringValue) {
- return stringValue == null || stringValue.trim().length() == 0;
- }
-
private String getDefaultCredential() {
return new String(Base64.getDecoder().decode(DEFAULT_SECURITY_CREDENTIALS.getBytes()));
}
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <consoleOutput>true</consoleOutput>
+ <failOnViolation>true</failOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</build>
// @formatter:off
this.manager = new ServiceManager()
.addAction("topics",
- () -> TopicEndpoint.manager.start(),
- () -> TopicEndpoint.manager.shutdown())
+ () -> TopicEndpoint.manager.start(),
+ () -> TopicEndpoint.manager.shutdown())
.addAction("set alive",
- () -> setAlive(true),
- () -> setAlive(false))
+ () -> setAlive(true),
+ () -> setAlive(false))
.addAction("register pdp status context object",
- () -> Registry.register(ApexStarterConstants.REG_PDP_STATUS_OBJECT,
+ () -> Registry.register(ApexStarterConstants.REG_PDP_STATUS_OBJECT,
new PdpMessageHandler().createPdpStatusFromParameters(instanceId,
apexStarterParameterGroup.getPdpStatusParameters())),
- () -> Registry.unregister(ApexStarterConstants.REG_PDP_STATUS_OBJECT))
+ () -> Registry.unregister(ApexStarterConstants.REG_PDP_STATUS_OBJECT))
.addAction("topic sinks",
- () -> Registry.register(ApexStarterConstants.REG_APEX_PDP_TOPIC_SINKS, topicSinks),
- () -> Registry.unregister(ApexStarterConstants.REG_APEX_PDP_TOPIC_SINKS))
+ () -> Registry.register(ApexStarterConstants.REG_APEX_PDP_TOPIC_SINKS, topicSinks),
+ () -> Registry.unregister(ApexStarterConstants.REG_APEX_PDP_TOPIC_SINKS))
.addAction("Pdp Status publisher",
- () -> Registry.register(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER,
+ () -> Registry.register(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER,
new PdpStatusPublisher(topicSinks,
apexStarterParameterGroup.getPdpStatusParameters().getTimeIntervalMs())),
- () -> stopAndRemovePdpStatusPublisher())
+ () -> stopAndRemovePdpStatusPublisher())
.addAction("Register pdp update listener",
() -> msgDispatcher.register(PdpMessageType.PDP_UPDATE.name(), pdpUpdateListener),
() -> msgDispatcher.unregister(PdpMessageType.PDP_UPDATE.name()))
.addAction("Register pdp state change request dispatcher",
- () -> msgDispatcher.register(PdpMessageType.PDP_STATE_CHANGE.name(), pdpStateChangeListener),
- () -> msgDispatcher.unregister(PdpMessageType.PDP_STATE_CHANGE.name()))
+ () -> msgDispatcher.register(PdpMessageType.PDP_STATE_CHANGE.name(), pdpStateChangeListener),
+ () -> msgDispatcher.unregister(PdpMessageType.PDP_STATE_CHANGE.name()))
.addAction("Message Dispatcher",
() -> registerMsgDispatcher(),
() -> unregisterMsgDispatcher())
.addAction("Create REST server",
- () -> restServer =
+ () -> restServer =
new ApexStarterRestServer(apexStarterParameterGroup.getRestServerParameters()),
- () -> restServer = null)
+ () -> restServer = null)
.addAction("Rest Server",
- () -> restServer.start(),
- () -> restServer.stop());
+ () -> restServer.start(),
+ () -> restServer.stop());
// @formatter:on
}
import com.google.gson.JsonObject;
import java.io.IOException;
-import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@Api(value = "PDP-A API")
@Produces(MediaType.APPLICATION_JSON)
@SwaggerDefinition(
- info = @Info(description =
+ info = @Info(description =
"PDP-A is responsible for making policy decisions and for managing the administrative"
+ " state of the PDPs as directed by PolicyAdministration", version = "v1.0",
title = "PDP-A"),
- consumes = {MediaType.APPLICATION_JSON},
- produces = {MediaType.APPLICATION_JSON},
- schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
- tags = {@Tag(name = "PDP-A", description = "PDP-A Operations")},
- securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
+ consumes = {MediaType.APPLICATION_JSON},
+ produces = {MediaType.APPLICATION_JSON},
+ schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
+ tags = {@Tag(name = "PDP-A", description = "PDP-A Operations")},
+ securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
//@formatter:on
public class HealthCheckRestControllerV1 {
@Test
public void testApexStarter_InvalidParameters() {
final String[] apexStarterConfigParameters =
- { "-c", "src/test/resources/ApexStarterConfigParameters_InvalidName.json" };
+ { "-c", "src/test/resources/ApexStarterConfigParameters_InvalidName.json" };
apexStarter = new ApexStarterMain(apexStarterConfigParameters);
assertTrue(apexStarter.getParameters() == null);
}
@Test
public void testApexStarterParameterGroup_InvalidName() throws ApexStarterException {
final String[] apexStarterConfigParameters =
- { "-c", "src/test/resources/ApexStarterConfigParameters_InvalidName.json" };
+ { "-c", "src/test/resources/ApexStarterConfigParameters_InvalidName.json" };
final ApexStarterCommandLineArguments arguments = new ApexStarterCommandLineArguments();
arguments.parse(apexStarterConfigParameters);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator;
import java.util.List;
-
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.OutputEvent;
* Calculate statistics for a single event.
* @param eventBatch the event batch for the event
* @param eventNo the event number of the event
- * @return
+ * @return event timings
*/
private Pair<Long, Long> calculateEventTimings(EventBatch eventBatch, int eventNo) {
// If an event is in a batch, it has been sent