* <p>A context album uses plugins to handle its context schemas, its distribution, its locking, and
* its persistence.
*
- * <p>
- * The schema that defines the items in a context album is interpreted by a plugin that implements
+ * <p>The schema that defines the items in a context album is interpreted by a plugin that implements
* the {@link SchemaHelper} interface. The schema helper uses the schema definition to provide new
* instances for a context album. By default, context albums use Java schemas.
*
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
public class ContextAlbumImplTest {
+ /**
+ * Set ups everything for the test.
+ */
@BeforeClass
public static void prepareForTest() {
final ContextParameters contextParameters = new ContextParameters();
AxContextAlbum axContextAlbum = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
true, AxArtifactKey.getNullKey());
- AxContextAlbum axContextAlbumRO = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
- false, simpleStringSchema.getKey());
-
try {
new ContextAlbumImpl(axContextAlbum, new JVMLocalDistributor(), new LinkedHashMap<String, Object>());
fail("this test should throw an exception");
Distributor distributor = new JVMLocalDistributor();
distributor.init(axContextAlbum.getKey());
ContextAlbum album = new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<String, Object>());
- ContextAlbum albumRO = new ContextAlbumImpl(axContextAlbumRO, distributor, new LinkedHashMap<String, Object>());
+
+ AxContextAlbum axContextAlbumRo = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
+ false, simpleStringSchema.getKey());
+ ContextAlbum albumRo = new ContextAlbumImpl(axContextAlbumRo, distributor, new LinkedHashMap<String, Object>());
assertEquals("TestContextAlbum", album.getName());
assertEquals("TestContextAlbum:0.0.1", album.getKey().getID());
}
try {
- albumRO.put("KeyReadOnly", "A value for a Read Only Album");
+ albumRo.put("KeyReadOnly", "A value for a Read Only Album");
fail("test should throw an exception");
} catch (ContextRuntimeException e) {
assertEquals("album \"TestContextAlbum:0.0.1\" put() not allowed on read only albums "
putAllData.put("AllKey2", "vaue of AllKey2");
try {
- albumRO.putAll(putAllData);
+ albumRo.putAll(putAllData);
fail("test should throw an exception");
} catch (ContextRuntimeException e) {
assertEquals("album \"TestContextAlbum:0.0.1\" putAll() not allowed on read only albums", e.getMessage());
}
try {
- albumRO.remove("AllKey0");
+ albumRo.remove("AllKey0");
fail("test should throw an exception");
} catch (ContextRuntimeException e) {
assertEquals(
}
try {
- albumRO.clear();
+ albumRo.clear();
fail("test should throw an exception");
} catch (ContextRuntimeException e) {
assertEquals("album \"TestContextAlbum:0.0.1\" clear() not allowed on read only albums", e.getMessage());
private static AxContextSchemas schemas;
private static AxContextSchema badSchema;
+ /**
+ * Set ups schema for the test.
+ */
@BeforeClass
public static void setupSchema() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
+ /**
+ * Set ups everything for the test.
+ */
@Before
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonPrimitive;
+
import java.math.BigDecimal;
import org.junit.Test;
+
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
public class JavaSchemaHelperTest {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: class/type java.lang.Rubbish for context schema"
- + " \"SchemaKey:0.0.1\" not found. Check the class path of the JVM", e.getMessage());
+ + " \"SchemaKey:0.0.1\" not found. Check the class path of the JVM", e.getMessage());
}
AxContextSchema builtInJavaTypeSchema = new AxContextSchema(schemaKey, "Java", "short");
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: class/type short for context schema "
- + "\"SchemaKey:0.0.1\" not found. Primitive types are not supported."
- + " Use the appropriate Java boxing type instead.", e.getMessage());
+ + "\"SchemaKey:0.0.1\" not found. Primitive types are not supported."
+ + " Use the appropriate Java boxing type instead.", e.getMessage());
}
}
@Test
public void testJavaSchemaHelperMethods() {
- AxArtifactKey schemaKey = new AxArtifactKey("SchemaKey", "0.0.1");
- AxArtifactKey userKey = new AxArtifactKey("UserKey", "0.0.1");
-
- AxContextSchema intSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Integer");
-
SchemaHelper intSchemaHelper = new JavaSchemaHelper();
assertEquals(AxArtifactKey.getNullKey(), intSchemaHelper.getUserKey());
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("NULL:0.0.0: could not create an instance, schema class for the schema is null",
- e.getMessage());
+ e.getMessage());
}
try {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("NULL:0.0.0: could not create an instance, schema class for the schema is null",
- e.getMessage());
+ e.getMessage());
}
try {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("NULL:0.0.0: could not create an instance, schema class for the schema is null",
- e.getMessage());
+ e.getMessage());
}
+ AxArtifactKey schemaKey = new AxArtifactKey("SchemaKey", "0.0.1");
+ AxArtifactKey userKey = new AxArtifactKey("UserKey", "0.0.1");
+ AxContextSchema intSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Integer");
+
intSchemaHelper.init(userKey, intSchema);
assertEquals(userKey, intSchemaHelper.getUserKey());
assertEquals(intSchema, intSchemaHelper.getSchema());
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: could not create an instance of class "
- + "\"java.lang.Integer\" using the default constructor \"Integer()\"", e.getMessage());
+ + "\"java.lang.Integer\" using the default constructor \"Integer()\"", e.getMessage());
}
try {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: the object \"1.23\" of type "
- + "\"java.lang.Float\" is not an instance of JsonObject and is not "
- + "assignable to \"java.lang.Integer\"", e.getMessage());
+ + "\"java.lang.Float\" is not an instance of JsonObject and is not "
+ + "assignable to \"java.lang.Integer\"", e.getMessage());
}
try {
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: could not create an instance of class \"java.lang.Integer\" "
- + "using the string constructor \"Integer(String)\"", e.getMessage());
+ + "using the string constructor \"Integer(String)\"", e.getMessage());
}
JsonElement jsonIntElement = null;
AxContextSchema byteSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Byte");
AxContextSchema shortSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Short");
AxContextSchema intSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Integer");
- AxContextSchema longSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Long");
- AxContextSchema floatSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Float");
- AxContextSchema doubleSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Double");
- AxContextSchema stringSchema = new AxContextSchema(schemaKey, "Java", "java.lang.String");
- AxContextSchema myBaseClassSchema = new AxContextSchema(schemaKey, "Java",
- "org.onap.policy.apex.context.impl.schema.java.MyBaseClass");
SchemaHelper byteSchemaHelper = new JavaSchemaHelper();
SchemaHelper shortSchemaHelper = new JavaSchemaHelper();
SchemaHelper intSchemaHelper = new JavaSchemaHelper();
- SchemaHelper longSchemaHelper = new JavaSchemaHelper();
- SchemaHelper floatSchemaHelper = new JavaSchemaHelper();
- SchemaHelper doubleSchemaHelper = new JavaSchemaHelper();
- SchemaHelper stringSchemaHelper = new JavaSchemaHelper();
- SchemaHelper myBaseClassSchemaHelper = new JavaSchemaHelper();
byteSchemaHelper.init(userKey, byteSchema);
shortSchemaHelper.init(userKey, shortSchema);
intSchemaHelper.init(userKey, intSchema);
+
+ SchemaHelper longSchemaHelper = new JavaSchemaHelper();
+ SchemaHelper floatSchemaHelper = new JavaSchemaHelper();
+
+ AxContextSchema longSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Long");
+ AxContextSchema floatSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Float");
longSchemaHelper.init(userKey, longSchema);
floatSchemaHelper.init(userKey, floatSchema);
+
+ SchemaHelper doubleSchemaHelper = new JavaSchemaHelper();
+ SchemaHelper stringSchemaHelper = new JavaSchemaHelper();
+ AxContextSchema doubleSchema = new AxContextSchema(schemaKey, "Java", "java.lang.Double");
+ AxContextSchema stringSchema = new AxContextSchema(schemaKey, "Java", "java.lang.String");
doubleSchemaHelper.init(userKey, doubleSchema);
stringSchemaHelper.init(userKey, stringSchema);
+
+ AxContextSchema myBaseClassSchema =
+ new AxContextSchema(schemaKey, "Java", "org.onap.policy.apex.context.impl.schema.java.MyBaseClass");
+ SchemaHelper myBaseClassSchemaHelper = new JavaSchemaHelper();
myBaseClassSchemaHelper.init(userKey, myBaseClassSchema);
assertEquals(null, byteSchemaHelper.unmarshal(null));
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Byte\"", e.getMessage());
+ + "compatible with class \"java.lang.Byte\"", e.getMessage());
}
assertEquals(null, shortSchemaHelper.unmarshal(null));
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Short\"", e.getMessage());
+ + "compatible with class \"java.lang.Short\"", e.getMessage());
}
assertEquals(null, intSchemaHelper.unmarshal(null));
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Integer\"", e.getMessage());
+ + "compatible with class \"java.lang.Integer\"", e.getMessage());
}
assertEquals(null, longSchemaHelper.unmarshal(null));
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Long\"", e.getMessage());
+ + "compatible with class \"java.lang.Long\"", e.getMessage());
}
assertEquals(null, floatSchemaHelper.unmarshal(null));
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Float\"", e.getMessage());
+ + "compatible with class \"java.lang.Float\"", e.getMessage());
}
assertEquals(null, doubleSchemaHelper.unmarshal(null));
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Double\"", e.getMessage());
+ + "compatible with class \"java.lang.Double\"", e.getMessage());
}
assertEquals("123", stringSchemaHelper.unmarshal(123));
fail("test should throw an exception here");
} catch (ContextRuntimeException e) {
assertEquals("UserKey:0.0.1: object \"123.45\" of class \"java.lang.Double\" not "
- + "compatible with class \"java.lang.Integer\"", e.getMessage());
+ + "compatible with class \"java.lang.Integer\"", e.getMessage());
}
-
+
JsonPrimitive intJsonPrimitive = (JsonPrimitive) intSchemaHelper.marshal2Object(123);
assertEquals(123, intJsonPrimitive.getAsInt());
}
* @author Sergey Sachkov (sergey.sachkov@ericsson.com)
*/
public class ContextInstantiation {
-
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextInstantiation.class);
- private final static TreeSet<String> TEST_TREE_SET = new TreeSet<>();
- private final static Map<String, String> TEST_HASH_MAP = new HashMap<>();
+ private static final TreeSet<String> TEST_TREE_SET = new TreeSet<>();
+ private static final Map<String, String> TEST_HASH_MAP = new HashMap<>();
static {
TEST_TREE_SET.add("one hundred");
return globalContext;
}
+ private TestGlobalContextItem getTestGlobalContextItem(final Date testDate, final TestContextDateTzItem tci9,
+ final TestContextDateLocaleItem tciA) {
+ final TestGlobalContextItem globalContext = new TestGlobalContextItem();
+
+ final TestContextBooleanItem testGlobalContextItem000 = new TestContextBooleanItem(false);
+ final TestContextByteItem testGlobalContextItem001 = new TestContextByteItem(BYTE_VAL);
+ final TestContextIntItem testGlobalContextItem002 = new TestContextIntItem(INT_VAL);
+ final TestContextLongItem testGlobalContextItem003 = new TestContextLongItem(LONG_VAL);
+ final TestContextFloatItem testGlobalContextItem004 = new TestContextFloatItem(new Float(FLOAT_VAL));
+ final TestContextDoubleItem testGlobalContextItem005 = new TestContextDoubleItem(PI_VAL);
+ final TestContextStringItem testGlobalContextItem006 = new TestContextStringItem(STRING_GLOBAL_VAL);
+ final TestContextLongObjectItem testGlobalContextItem007 = new TestContextLongObjectItem(testDate.getTime());
+
+ final TestContextDateItem testGlobalContextItem008 = new TestContextDateItem(testDate);
+ final TestContextTreeSetItem testGlobalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET);
+ final TestContextTreeMapItem testGlobalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP);
+
+
+ globalContext.setTestGlobalContextItem000(testGlobalContextItem000);
+ globalContext.setTestGlobalContextItem001(testGlobalContextItem001);
+ globalContext.setTestGlobalContextItem002(testGlobalContextItem002);
+ globalContext.setTestGlobalContextItem003(testGlobalContextItem003);
+ globalContext.setTestGlobalContextItem004(testGlobalContextItem004);
+ globalContext.setTestGlobalContextItem005(testGlobalContextItem005);
+ globalContext.setTestGlobalContextItem006(testGlobalContextItem006);
+ globalContext.setTestGlobalContextItem007(testGlobalContextItem007);
+ globalContext.setTestGlobalContextItem008(testGlobalContextItem008);
+ globalContext.setTestGlobalContextItem009(tci9);
+ globalContext.setTestGlobalContextItem00A(tciA);
+ globalContext.setTestGlobalContextItem00B(testGlobalContextItem00B);
+ globalContext.setTestGlobalContextItem00C(testGlobalContextItem00C);
+ return globalContext;
+ }
+
private TestPolicyContextItem getTestPolicyContextItem(final ContextAlbum policyContextAlbum, final Date testDate) {
final TestContextStringItem contextStringItem = new TestContextStringItem(STRING_VAL);
final TestContextLongItem contextLongItem = new TestContextLongItem(LONG_VAL);
return tci9;
}
- private TestGlobalContextItem getTestGlobalContextItem(final Date testDate, final TestContextDateTzItem tci9,
- final TestContextDateLocaleItem tciA) {
- final TestGlobalContextItem globalContext = new TestGlobalContextItem();
-
- final TestContextBooleanItem testGlobalContextItem000 = new TestContextBooleanItem(false);
- final TestContextByteItem testGlobalContextItem001 = new TestContextByteItem(BYTE_VAL);
- final TestContextIntItem testGlobalContextItem002 = new TestContextIntItem(INT_VAL);
- final TestContextLongItem testGlobalContextItem003 = new TestContextLongItem(LONG_VAL);
- final TestContextFloatItem testGlobalContextItem004 = new TestContextFloatItem(new Float(FLOAT_VAL));
- final TestContextDoubleItem testGlobalContextItem005 = new TestContextDoubleItem(PI_VAL);
- final TestContextStringItem testGlobalContextItem006 = new TestContextStringItem(STRING_GLOBAL_VAL);
- final TestContextLongObjectItem testGlobalContextItem007 = new TestContextLongObjectItem(testDate.getTime());
-
- final TestContextDateItem testGlobalContextItem008 = new TestContextDateItem(testDate);
- final TestContextTreeSetItem testGlobalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET);
- final TestContextTreeMapItem testGlobalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP);
-
-
- globalContext.setTestGlobalContextItem000(testGlobalContextItem000);
- globalContext.setTestGlobalContextItem001(testGlobalContextItem001);
- globalContext.setTestGlobalContextItem002(testGlobalContextItem002);
- globalContext.setTestGlobalContextItem003(testGlobalContextItem003);
- globalContext.setTestGlobalContextItem004(testGlobalContextItem004);
- globalContext.setTestGlobalContextItem005(testGlobalContextItem005);
- globalContext.setTestGlobalContextItem006(testGlobalContextItem006);
- globalContext.setTestGlobalContextItem007(testGlobalContextItem007);
- globalContext.setTestGlobalContextItem008(testGlobalContextItem008);
- globalContext.setTestGlobalContextItem009(tci9);
- globalContext.setTestGlobalContextItem00A(tciA);
- globalContext.setTestGlobalContextItem00B(testGlobalContextItem00B);
- globalContext.setTestGlobalContextItem00C(testGlobalContextItem00C);
- return globalContext;
- }
-
private TestExternalContextItem getTestExternalContextItem(final Date testDate, final TestContextDateTzItem tci9A,
final TestContextDateLocaleItem tciAA) {
final TestExternalContextItem externalContext = new TestExternalContextItem();
return value;
}
+ /**
+ * Get the lock type given an int value.
+ * @param value the value of lock type
+ * @return the lock type
+ */
public static LockType getLockType(final int value) {
for (final LockType lockType : LockType.values()) {
if (lockType.getValue() == value) {
// The context distributor and map used by each test
private Distributor contextDistributor = null;
- private ContextAlbum lTypeAlbum = null;
+ private ContextAlbum ltypeAlbum = null;
private final ConfigrationProvider configrationProvider;
this.configrationProvider = configrationProvider;
}
+ /**
+ * The method tests concurrent use of context.
+ * @return the verified context
+ * @throws ApexModelException the exception occurs in model handling
+ * @throws IOException the IO exception occurs in handling IO
+ * @throws ApexException the Apex exception occurs in handling Apex
+ */
public Map<String, TestContextLongItem> testConcurrentContext()
throws ApexModelException, IOException, ApexException {
*/
private void setupAndVerifyContext() throws ContextException {
contextDistributor = configrationProvider.getDistributor();
- lTypeAlbum = configrationProvider.getContextAlbum(contextDistributor);
+ ltypeAlbum = configrationProvider.getContextAlbum(contextDistributor);
final Map<String, Object> initValues = configrationProvider.getContextAlbumInitValues();
for (final Entry<String, Object> entry : initValues.entrySet()) {
- lTypeAlbum.put(entry.getKey(), entry.getValue());
+ ltypeAlbum.put(entry.getKey(), entry.getValue());
}
}
final Map<String, TestContextLongItem> values = new HashMap<>();
try {
- for (Entry<String, Object> entry : lTypeAlbum.entrySet()) {
+ for (Entry<String, Object> entry : ltypeAlbum.entrySet()) {
values.put(entry.getKey(), (TestContextLongItem) entry.getValue());
}
} catch (final Exception exception) {
package org.onap.policy.apex.context.test.locking;
+import com.google.gson.Gson;
+
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.ArrayList;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-import com.google.gson.Gson;
/**
* The Class ConcurrentContextJVM tests concurrent use of context in a single JVM.
this.executorService = configrationProvider.getExecutorService(name, configrationProvider.getThreadCount());
}
+ /**
+ * This method executes the test of concurrent use of context in a single JVM.
+ * @throws ApexException the Apex exception occurs while running the test
+ */
public void execute() throws ApexException {
LOGGER.debug("starting JVMs and threads . . .");
/**
- * This method setus up any static configuration required by the JVM.
+ * This method sets up any static configuration required by the JVM.
*
* @throws Exception on configuration errors
*/
package org.onap.policy.apex.context.test.locking;
+import com.google.gson.Gson;
+
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.InputStream;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-import com.google.gson.Gson;
+
/**
* The Class TestConcurrentContextThread tests concurrent use of context.
private final int albumSize;
private final LockType lockType;
+ /**
+ * The parameterized ConfigrationProviderImpl constructor.
+ * @param testType the test type
+ * @param jvmCount the JVM count
+ * @param threadCount the thread count
+ * @param loopSize the size of loop
+ * @param albumSize the size of album
+ * @param lockType the lock type
+ */
public ConfigrationProviderImpl(final String testType, final int jvmCount, final int threadCount,
final int loopSize, final int albumSize, final int lockType) {
this.testType = testType;
import org.apache.zookeeper.server.NIOServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
this.addr = new InetSocketAddress(addr, port);
}
+ /**
+ * Start the Zookeeper server.
+ * @throws IOException the IO exception occurs while setting up Zookeeper server
+ * @throws InterruptedException the interrupted exception occurs while setting up Zookeeper server
+ */
public void startZookeeperServer() throws IOException, InterruptedException {
LOGGER.info("Starting up ZooKeeperServer using address: {} and port: {}", addr.getAddress(), addr.getPort());
final ZooKeeperServer server = new ZooKeeperServer(zookeeperDirectory, zookeeperDirectory, 5000);
zookeeperFactory.startup(server);
}
+ /**
+ * Stop the Zookeeper server.
+ */
public void stopZookeeperServer() {
LOGGER.info("Stopping ZooKeeperServer for address: {} and port: {}", addr.getAddress(), addr.getPort());
if (zookeeperFactory != null) {
final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
final AxArtifactKey[] usedArtifactStackArray = {new AxArtifactKey("testC-top", "0.0.1"),
- new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1")};
+ new AxArtifactKey("testC-next", "0.0.1"), new AxArtifactKey("testC-bot", "0.0.1")};
final DAOParameters daoParameters = new DAOParameters();
daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
* Gets the parameters for event.
*
* @param cg the code generator
- * @param e the event
+ * @param event the event
* @return the parameters for event
*/
- private List<ST> getParametersForEvent(final CGCliEditor cg, final AxEvent e) {
- final Collection<AxField> fields = e.getFields();
+ private List<ST> getParametersForEvent(final CGCliEditor cg, final AxEvent event) {
+ final Collection<AxField> fields = event.getFields();
final List<ST> ret = new ArrayList<>(fields.size());
for (final AxField f : fields) {
final AxReferenceKey fkey = f.getKey();
* Gets the context references for task.
*
* @param cg the code generator
- * @param t the task
+ * @param task the task
* @return the context references for task
*/
- private List<ST> getCtxtRefsForTask(final CGCliEditor cg, final AxTask t) {
- final Collection<AxArtifactKey> ctxs = t.getContextAlbumReferences();
+ private List<ST> getCtxtRefsForTask(final CGCliEditor cg, final AxTask task) {
+ final Collection<AxArtifactKey> ctxs = task.getContextAlbumReferences();
final List<ST> ret = new ArrayList<>(ctxs.size());
- final AxArtifactKey tkey = t.getKey();
+ final AxArtifactKey tkey = task.getKey();
for (final AxArtifactKey ckey : ctxs) {
final ST val = cg.createTaskDefinitionContextRef(kig.getName(tkey), kig.getVersion(tkey), kig.getName(ckey),
* Gets the parameters for task.
*
* @param cg the code generator
- * @param t the task
+ * @param task the task
* @return the parameters for task
*/
- private List<ST> getParametersForTask(final CGCliEditor cg, final AxTask t) {
- final Collection<AxTaskParameter> pars = t.getTaskParameters().values();
+ private List<ST> getParametersForTask(final CGCliEditor cg, final AxTask task) {
+ final Collection<AxTaskParameter> pars = task.getTaskParameters().values();
final List<ST> ret = new ArrayList<>(pars.size());
for (final AxTaskParameter p : pars) {
final AxReferenceKey pkey = p.getKey();
* Gets the logic for task.
*
* @param cg the code generator
- * @param t the task
+ * @param task the task
* @return the logic for task
*/
- private ST getLogicForTask(final CGCliEditor cg, final AxTask t) {
- final AxArtifactKey tkey = t.getKey();
- final AxTaskLogic tl = t.getTaskLogic();
+ private ST getLogicForTask(final CGCliEditor cg, final AxTask task) {
+ final AxArtifactKey tkey = task.getKey();
+ final AxTaskLogic tl = task.getTaskLogic();
final ST val =
cg.createTaskDefLogic(kig.getName(tkey), kig.getVersion(tkey), tl.getLogicFlavour(), tl.getLogic());
* Gets the output fields for task.
*
* @param cg the code generator
- * @param t the task
+ * @param task the task
* @return the output fields for task
*/
- private List<ST> getOutfieldsForTask(final CGCliEditor cg, final AxTask t) {
- final Collection<? extends AxField> fields = t.getOutputFields().values();
+ private List<ST> getOutfieldsForTask(final CGCliEditor cg, final AxTask task) {
+ final Collection<? extends AxField> fields = task.getOutputFields().values();
final List<ST> ret = new ArrayList<>(fields.size());
for (final AxField f : fields) {
final AxReferenceKey fkey = f.getKey();
* Gets the input fields for task.
*
* @param cg the code generator
- * @param t the task
+ * @param task the task
* @return the input fields for task
*/
- private List<ST> getInfieldsForTask(final CGCliEditor cg, final AxTask t) {
- final Collection<? extends AxField> fields = t.getInputFields().values();
+ private List<ST> getInfieldsForTask(final CGCliEditor cg, final AxTask task) {
+ final Collection<? extends AxField> fields = task.getInputFields().values();
final List<ST> ret = new ArrayList<>(fields.size());
for (final AxField f : fields) {
final AxReferenceKey fkey = f.getKey();
* Gets the states for policy.
*
* @param cg the code generator
- * @param p the policy
+ * @param pol the policy
* @return the states for policy
*/
- private List<ST> getStatesForPolicy(final CGCliEditor cg, final AxPolicy p) {
- final Collection<AxState> states = p.getStateMap().values();
+ private List<ST> getStatesForPolicy(final CGCliEditor cg, final AxPolicy pol) {
+ final Collection<AxState> states = pol.getStateMap().values();
final List<ST> ret = new ArrayList<>(states.size());
for (final AxState st : states) {
final AxReferenceKey skey = st.getKey();
/**
* Runs the application.
*
+ *
+ * @return status of the application execution, 0 for success, positive integer for exit
+ * condition (such as help or version), negative integer for errors
* @throws ApexException if any problem occurred in the model
- * @return status of the application execution, 0 for success, positive integer for exit condition (such as help or
- * version), negative integer for errors
*/
public int runApp() throws ApexException {
final STGroupFile stg = new STGroupFile("org/onap/policy/apex/tools/model/generator/event-json.stg");
/** A type option defining what type is used for events with "-t" and "--type". */
public static final Option TYPE = Option.builder("t").hasArg().argName("TYPE").longOpt("type").desc(
- "set the event type for generation, one of: stimuli (trigger events), response (action events), internal (events between states)")
+ "set the event type for generation, one of: stimuli (trigger events), response (action events),"
+ + " internal (events between states)")
.build();
/** A server option with "-s" and "--server". */
types = type;
}
- /**
- * Configures the console. Use the configuration flags in combination for the required configuration. For instance,
- * to collect errors and warnings use <code>CONFIG_COLLECT_ERRORS | CONFIG_COLLECT_WARNINGS</code>.
- *
- * @param config the new configuration, overwrites the current configuration, 0 deactivates all settings
- */
- public void configure(final int config) {
- this.configuration = config;
- }
-
/**
* Sets the type to the given types, effectively deactivating all other types.
*
}
}
+ /**
+ * Configures the console. Use the configuration flags in combination for the required configuration. For instance,
+ * to collect errors and warnings use <code>CONFIG_COLLECT_ERRORS | CONFIG_COLLECT_WARNINGS</code>.
+ *
+ * @param config the new configuration, overwrites the current configuration, 0 deactivates all settings
+ */
+ public void configure(final int config) {
+ this.configuration = config;
+ }
+
/**
* Prints an error message with message and objects if {@link #TYPE_ERROR} is set; and increases the error count.
* Errors are collected (if configuration is set) and the error counter is increased regardless of the console error