public interface Lockable {
/**
- * locks this entity
+ * Locks this entity.
*
* @return true is the lock operation was successful, false otherwise
*/
public boolean lock();
/**
- * unlocks this entity
+ * Unlocks this entity.
*
* @return true is the unlock operation was successful, false otherwise
*/
public boolean unlock();
/**
- * is this entity locked?
+ * Checks if this entity is locked.
*
* @return true if the entity is in a locked state, false otherwise
*/
public void shutdown();
/**
- * is it alive?
+ * Checks if the entity is alive.
*
* @return boolean. true if alive, otherwise false
*/
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
- <version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.7.12</version>
</dependency>
<dependency>
<groupId>com.att.eelf</groupId>
}
/**
- * Construct a validation result for a field
+ * Construct a validation result for a field.
*
* @param field The parameter field
* @param ParameterGroup The parameter group containing the field
/**
* Set the validation result on on a parameter group.
- *
* On a sequence of calls, the most serious validation status is recorded, assuming the status enum ordinal increase
* in order of severity
*
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import org.junit.Test;
import org.onap.policy.common.parameters.testclasses.TestParametersL00;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
public class TestJsonInput {
try {
// Read the parameters from JSON using Gson
final Gson gson = new GsonBuilder().create();
- testParameterGroup = gson.fromJson(new FileReader("src/test/resources/parameters/TestParameters.json"), TestParametersL00.class);
+ testParameterGroup = gson.fromJson(new FileReader("src/test/resources/parameters/TestParameters.json"),
+ TestParametersL00.class);
} catch (final Exception e) {
fail("test should not throw an exception here: " + e.getMessage());
}
GroupValidationResult validationResult = testParameterGroup.validate();
assertTrue(validationResult.isValid());
assertEquals("l00NameFromFile", testParameterGroup.getName());
-
+
String expectedResult = new String(Files.readAllBytes(
Paths.get("src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt")))
.replaceAll("\\s+", "");
try {
// Read the parameters from JSON using Gson
final Yaml yaml = new Yaml();
- testParameterGroup = yaml.loadAs(new FileReader("src/test/resources/parameters/TestParameters.yaml"), TestParametersL00.class);
+ testParameterGroup = yaml.loadAs(new FileReader("src/test/resources/parameters/TestParameters.yaml"),
+ TestParametersL00.class);
} catch (final Exception e) {
fail("test should not throw an exception here: " + e.getMessage());
}
GroupValidationResult validationResult = testParameterGroup.validate();
assertTrue(validationResult.isValid());
assertEquals("l00NameFromFile", testParameterGroup.getName());
-
+
String expectedResult = new String(Files.readAllBytes(
Paths.get("src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt")))
.replaceAll("\\s+", "");
package org.onap.policy.common.parameters.testclasses;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
public class EmptyParameterGroup implements ParameterGroup {
private String name;
package org.onap.policy.common.parameters.testclasses;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
public class ParameterGroupWithArray implements ParameterGroup {
private String name;
import java.util.ArrayList;
import java.util.List;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
public class ParameterGroupWithCollection implements ParameterGroup {
private String name;
/**
* Create a test parameter group.
+ *
* @param name the parameter group name
*/
public ParameterGroupWithCollection(final String name) {
this.name = name;
-
+
intArrayList.add(1);
intArrayList.add(2);
intArrayList.add(3);
public List<Integer> getIntArrayList() {
return intArrayList;
}
-
+
@Override
public String getName() {
return name;
}
-
+
@Override
public GroupValidationResult validate() {
return new GroupValidationResult(this);
import java.util.LinkedHashMap;
import java.util.Map;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
public class ParameterGroupWithIllegalMapKey implements ParameterGroup {
private String name;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
public class ParameterGroupWithIllegalMapValue implements ParameterGroup {
private String name;
import java.util.List;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
public class ParameterGroupWithNullCollection implements ParameterGroup {
private String name;
import java.util.Map;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
public class ParameterGroupWithNullMapValue implements ParameterGroup {
private String name;
import java.util.ArrayList;
import java.util.List;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
public class ParameterGroupWithParameterGroupCollection implements ParameterGroup {
private String name;
import java.util.Map;
import java.util.Map.Entry;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterConstants;
+import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ValidationStatus;
public class TestParametersL00 implements ParameterGroup {
private Map<String, TestParametersLGeneric> l00LGenericNestedMap = new LinkedHashMap<>();
/**
- * Default constructor
+ * Default constructor.
*/
public TestParametersL00() {
+ // Default Cnstructor
}
/**
import java.util.Map;
import java.util.Map.Entry;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterConstants;
+import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ValidationStatus;
public class TestParametersL10 implements ParameterGroup {
private Map<String, TestParametersLGeneric> l10LGenericNestedMap = new LinkedHashMap<>();
/**
- * Default constructor
+ * Default constructor.
*/
public TestParametersL10() {
+ // Default Constructor
}
/**
package org.onap.policy.common.parameters.testclasses;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterConstants;
+import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ValidationStatus;
public class TestParametersLGeneric implements ParameterGroup {
private String lgenericStringField = "Legal " + this.getClass().getCanonicalName();
/**
- * Default constructor
+ * Default constructor.
*/
public TestParametersLGeneric() {
+ // Default Constructor
}
/**
<dependency>
<groupId>com.att.nsa</groupId>
<artifactId>cambriaClient</artifactId>
- <version>${cambria.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>${http.client.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
- <version>${http.core.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
- <version>${jersey.swagger.version}</version>
</dependency>
<dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
- <version>${javax.persistence.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>