From a02548ec2e98a8a13cd76ecc83379b13cd26030b Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 20 Sep 2018 21:13:19 +0100 Subject: Fix bug with POJO events in APex When an envet should be decoded entirely into a POJO and is too complex for Avro, apex decoding breaks. This reviuew fixes thsi issue. Issue-ID: POLICY-1034 Change-Id: Iccd739c4bb5c1645a2a7165f5bbfdfd4b964d79e Signed-off-by: liamfallon --- .../engine/event/TestJsonEventConverter.java | 107 +++++++++ .../service/engine/event/TestJsonEventHandler.java | 5 +- .../engine/event/TestJsonEventHandlerForPojo.java | 245 +++++++++++++++++++++ .../event/TestJsonEventProtocolPrameters.java | 66 ++++++ .../service/engine/event/testpojos/TestPojo.java | 69 ++++++ .../engine/event/testpojos/TestPojoList.java | 39 ++++ .../engine/event/testpojos/TestSubPojo.java | 69 ++++++ .../engine/event/testpojos/TestSubSubPojo.java | 57 +++++ ...SuperTokenDelimitedEventProtocolParameters.java | 3 +- 9 files changed, 656 insertions(+), 4 deletions(-) create mode 100644 services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventConverter.java create mode 100644 services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandlerForPojo.java create mode 100644 services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventProtocolPrameters.java create mode 100644 services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojo.java create mode 100644 services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojoList.java create mode 100644 services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubPojo.java create mode 100644 services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubSubPojo.java (limited to 'services/services-engine/src/test/java/org/onap') diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventConverter.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventConverter.java new file mode 100644 index 000000000..471f90425 --- /dev/null +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventConverter.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.service.engine.event; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import org.junit.Test; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters; +import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParameters; + +/** + * Test the JSON event converter corner cases. + * + */ +public class TestJsonEventConverter { + + @Test + public void testJsonEventConverter() { + Apex2JsonEventConverter converter = new Apex2JsonEventConverter(); + + try { + converter.init(null); + fail("test should throw an exception"); + } catch (Exception ie) { + assertEquals("specified consumer properties are not applicable to the JSON event protocol", + ie.getMessage()); + } + + try { + converter.init(new EventProtocolParameters() { + }); + fail("test should throw an exception"); + } catch (Exception ie) { + assertEquals("specified consumer properties are not applicable to the JSON event protocol", + ie.getMessage()); + } + + JsonEventProtocolParameters pars = new JsonEventProtocolParameters(); + converter.init(pars); + + try { + converter.toApexEvent(null, null); + fail("test should throw an exception"); + } catch (Exception tae) { + assertEquals("event processing failed, event is null", tae.getMessage()); + } + + try { + converter.toApexEvent(null, 1); + fail("test should throw an exception"); + } catch (Exception tae) { + assertEquals("error converting event \"1\" to a string", tae.getMessage()); + } + + try { + converter.toApexEvent(null, "[{\"aKey\": 1},{\"aKey\": 2}]"); + fail("test should throw an exception"); + } catch (Exception tae) { + assertEquals("Failed to unmarshal JSON event: incoming event ([{\"aKey\": 1},{\"aKey\": 2}]) " + + "is a JSON object array containing an invalid object " + + "{aKey=1.0}, event=[{\"aKey\": 1},{\"aKey\": 2}]", tae.getMessage()); + } + + try { + converter.toApexEvent(null, "[1,2,3]"); + fail("test should throw an exception"); + } catch (Exception tae) { + assertEquals("Failed to unmarshal JSON event: incoming event ([1,2,3]) is a JSON object array " + + "containing an invalid object 1.0, event=[1,2,3]", tae.getMessage()); + } + + try { + converter.fromApexEvent(null); + fail("test should throw an exception"); + } catch (Exception tae) { + assertEquals("event processing failed, Apex event is null", tae.getMessage()); + } + + try { + converter.fromApexEvent(new ApexEvent("Event", "0.0.1", "a.name.space", "here", "there")); + fail("test should throw an exception"); + } catch (Exception tae) { + assertEquals("Model for org.onap.policy.apex.model.eventmodel.concepts.AxEvents not found in model service", + tae.getMessage()); + } + } +} diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java index cfe2921b8..a9165d792 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandler.java @@ -96,7 +96,7 @@ public class TestJsonEventHandler { } /** - * Test JSO nto apex event. + * Test JSON to apex event. * * @throws ApexException the apex exception */ @@ -134,7 +134,7 @@ public class TestJsonEventHandler { } /** - * Test JSO nto apex bad event. + * Test JSON to apex bad event. * * @throws ApexException the apex exception */ @@ -292,6 +292,7 @@ public class TestJsonEventHandler { public void testApexEventToJson() throws ApexException { try { final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter(); + jsonEventConverter.init(new JsonEventProtocolParameters()); assertNotNull(jsonEventConverter); final Date event0000StartTime = new Date(); diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandlerForPojo.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandlerForPojo.java new file mode 100644 index 000000000..1dae4c0f4 --- /dev/null +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventHandlerForPojo.java @@ -0,0 +1,245 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.service.engine.event; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.apex.context.parameters.ContextParameterConstants; +import org.onap.policy.apex.context.parameters.SchemaParameters; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader; +import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; +import org.onap.policy.apex.model.utilities.TextFileUtils; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.Apex2JsonEventConverter; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters; +import org.onap.policy.apex.service.engine.event.testpojos.TestPojo; +import org.onap.policy.apex.service.engine.event.testpojos.TestPojoList; +import org.onap.policy.common.parameters.ParameterService; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * Test JSON Event Handler. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class TestJsonEventHandlerForPojo { + private static final XLogger logger = XLoggerFactory.getXLogger(TestJsonEventHandlerForPojo.class); + + /** + * Setup event model. + * + * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexModelException the apex model exception + */ + @BeforeClass + public static void setupEventModel() throws IOException, ApexModelException { + final String policyModelString = TextFileUtils + .getTextFileAsString("src/test/resources/policymodels/PojoEventModel.json"); + final ApexModelReader modelReader = new ApexModelReader(AxPolicyModel.class); + modelReader.setValidateFlag(false); + final AxPolicyModel apexPolicyModel = modelReader.read(new ByteArrayInputStream(policyModelString.getBytes())); + + // Set up the models in the model service + apexPolicyModel.register(); + } + + /** + * Initialize default schema parameters. + */ + @BeforeClass + public static void initializeDefaultSchemaParameters() { + ParameterService.clear(); + final SchemaParameters schemaParameters = new SchemaParameters(); + schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); + ParameterService.register(schemaParameters); + } + + /** + * Teardown default schema parameters. + */ + @AfterClass + public static void teardownDefaultSchemaParameters() { + ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME); + } + + /** + * Test POJO to apex event and back. + * + * @throws ApexException the apex exception + * @throws IOException on IO exceptions + */ + @Test + public void testJsonPojoToApexEvent() throws ApexException, IOException { + final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter(); + assertNotNull(jsonEventConverter); + + JsonEventProtocolParameters pars = new JsonEventProtocolParameters(); + pars.setPojoField("POJO_PAR"); + jsonEventConverter.init(pars); + + final String apexEventJsonStringIn = TextFileUtils + .getTextFileAsString("src/test/resources/events/TestPojoEvent.json"); + + logger.debug("input event\n" + apexEventJsonStringIn); + + final List apexEventList = jsonEventConverter.toApexEvent("PojoEvent", apexEventJsonStringIn); + assertEquals(1, apexEventList.size()); + final ApexEvent apexEvent = apexEventList.get(0); + assertNotNull(apexEvent); + + logger.debug(apexEvent.toString()); + + assertEquals("PojoEvent", apexEvent.getName()); + assertEquals("0.0.1", apexEvent.getVersion()); + assertEquals("org.onap.policy.apex.service.engine.event.testpojos", apexEvent.getNameSpace()); + assertEquals("Outside", apexEvent.getSource()); + assertEquals("Apex", apexEvent.getTarget()); + + TestPojo testPojo = (TestPojo) apexEvent.get("POJO_PAR"); + + assertEquals(1, testPojo.getAnInt()); + assertEquals(2, testPojo.getAnInteger().intValue()); + assertEquals("a string", testPojo.getSomeString()); + + assertEquals(10, testPojo.getTestSubPojo().getAnInt()); + assertEquals(20, testPojo.getTestSubPojo().getAnInteger().intValue()); + assertEquals("a sub string", testPojo.getTestSubPojo().getSomeString()); + + assertEquals(100, testPojo.getTestSubPojo().getTestSubSubPojo().getAnInt()); + assertEquals(200, testPojo.getTestSubPojo().getTestSubSubPojo().getAnInteger().intValue()); + assertEquals("a sub sub string", testPojo.getTestSubPojo().getTestSubSubPojo().getSomeString()); + + String eventBackInJson = (String) jsonEventConverter.fromApexEvent(apexEvent); + assertEquals(apexEventJsonStringIn.replaceAll("\\s+", ""), eventBackInJson.replaceAll("\\s+", "")); + } + + /** + * Test POJO List to apex event and back. + * + * @throws ApexException the apex exception + * @throws IOException on IO exceptions + */ + @Test + public void testJsonPojoListToApexEvent() throws ApexException, IOException { + final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter(); + assertNotNull(jsonEventConverter); + + JsonEventProtocolParameters pars = new JsonEventProtocolParameters(); + pars.setPojoField("POJO_LIST_PAR"); + jsonEventConverter.init(pars); + + final String apexEventJsonStringIn = TextFileUtils + .getTextFileAsString("src/test/resources/events/TestPojoListEvent.json"); + + logger.debug("input event\n" + apexEventJsonStringIn); + + final List apexEventList = jsonEventConverter.toApexEvent("PojoListEvent", apexEventJsonStringIn); + assertEquals(1, apexEventList.size()); + final ApexEvent apexEvent = apexEventList.get(0); + assertNotNull(apexEvent); + + logger.debug(apexEvent.toString()); + + assertEquals("PojoListEvent", apexEvent.getName()); + assertEquals("0.0.1", apexEvent.getVersion()); + assertEquals("org.onap.policy.apex.service.engine.event.testpojos", apexEvent.getNameSpace()); + assertEquals("Outside", apexEvent.getSource()); + assertEquals("Apex", apexEvent.getTarget()); + + TestPojoList testPojoList = (TestPojoList) apexEvent.get("POJO_LIST_PAR"); + + for (TestPojo testPojo : testPojoList.getTestPojoList()) { + assertEquals(1, testPojo.getAnInt()); + assertEquals(2, testPojo.getAnInteger().intValue()); + assertEquals("a string", testPojo.getSomeString()); + + assertEquals(10, testPojo.getTestSubPojo().getAnInt()); + assertEquals(20, testPojo.getTestSubPojo().getAnInteger().intValue()); + assertEquals("a sub string", testPojo.getTestSubPojo().getSomeString()); + + assertEquals(100, testPojo.getTestSubPojo().getTestSubSubPojo().getAnInt()); + assertEquals(200, testPojo.getTestSubPojo().getTestSubSubPojo().getAnInteger().intValue()); + assertEquals("a sub sub string", testPojo.getTestSubPojo().getTestSubSubPojo().getSomeString()); + } + String eventBackInJson = (String) jsonEventConverter.fromApexEvent(apexEvent); + assertEquals(apexEventJsonStringIn.replaceAll("\\s+", ""), eventBackInJson.replaceAll("\\s+", "")); + } + + /** + * Test POJO event with bad configurations. + * + * @throws ApexException the apex exception + * @throws IOException on IO exceptions + */ + @Test + public void testJsonBadPojoApexEvent() throws ApexException, IOException { + final Apex2JsonEventConverter jsonEventConverter = new Apex2JsonEventConverter(); + assertNotNull(jsonEventConverter); + + JsonEventProtocolParameters pars = new JsonEventProtocolParameters(); + pars.setPojoField("BAD_POJO_PAR"); + jsonEventConverter.init(pars); + + final String apexEventJsonStringIn = TextFileUtils + .getTextFileAsString("src/test/resources/events/TestPojoEvent.json"); + + logger.debug("input event\n" + apexEventJsonStringIn); + + try { + jsonEventConverter.toApexEvent("PojoEvent", apexEventJsonStringIn); + fail("test should throw an exception"); + } catch (Exception tae) { + assertEquals("Failed to unmarshal JSON event: error parsing PojoEvent:0.0.1 event from Json. " + + "Field BAD_POJO_PAR not found on POJO event definition.", + tae.getMessage().substring(0, 133)); + } + + pars.setPojoField("POJO_PAR"); + try { + jsonEventConverter.toApexEvent("PojoNoFieldEvent", apexEventJsonStringIn); + fail("test should throw an exception"); + } catch (Exception tae) { + assertEquals("Failed to unmarshal JSON event: error parsing PojoNoFieldEvent:0.0.1 event from Json, " + + "Field POJO_PAR not found, no fields defined on event.", + tae.getMessage().substring(0, 139)); + } + + try { + jsonEventConverter.toApexEvent("PojoTooManyFieldsEvent", apexEventJsonStringIn); + fail("test should throw an exception"); + } catch (Exception tae) { + assertEquals("Failed to unmarshal JSON event: error parsing PojoTooManyFieldsEvent:0.0.1 event from Json, " + + "Field POJO_PAR, one and only one field may be defined on a POJO event definition.", + tae.getMessage().substring(0, 173)); + } + } +} diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventProtocolPrameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventProtocolPrameters.java new file mode 100644 index 000000000..139ea6b45 --- /dev/null +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/TestJsonEventProtocolPrameters.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.service.engine.event; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters; + +/** + * Test the JSON event parameters. + * + */ +public class TestJsonEventProtocolPrameters { + + @Test + public void testJsonParameters() { + assertNotNull(new JsonEventProtocolParameters()); + + JsonEventProtocolParameters params = new JsonEventProtocolParameters(); + + params.setLabel("MyLabel"); + assertEquals("MyLabel", params.getLabel()); + assertEquals("MyLabel", params.getName()); + + params.setEventProtocolPluginClass("MyPluginClass"); + assertEquals("MyPluginClass", params.getEventProtocolPluginClass()); + + params.setNameAlias("MyNameAlias"); + assertEquals("MyNameAlias", params.getNameAlias()); + + params.setVersionAlias("MyVersionAlias"); + assertEquals("MyVersionAlias", params.getVersionAlias()); + + params.setNameSpaceAlias("MyNameSpaceAlias"); + assertEquals("MyNameSpaceAlias", params.getNameSpaceAlias()); + + params.setSourceAlias("MySourceAlias"); + assertEquals("MySourceAlias", params.getSourceAlias()); + + params.setTargetAlias("MyTargetAlias"); + assertEquals("MyTargetAlias", params.getTargetAlias()); + + params.setPojoField("MyPojoField"); + assertEquals("MyPojoField", params.getPojoField()); + } +} diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojo.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojo.java new file mode 100644 index 000000000..009b2a756 --- /dev/null +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojo.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.service.engine.event.testpojos; + +/** + * A test Pojo for pojo decoding and encoding in Apex. + */ +public class TestPojo { + private int anInt; + private Integer anInteger; + private String someString; + + private TestSubPojo testSubPojo; + + /** + * Gets the an int. + * + * @return the an int + */ + public int getAnInt() { + return anInt; + } + + /** + * Gets the an integer. + * + * @return the an integer + */ + public Integer getAnInteger() { + return anInteger; + } + + /** + * Gets the a string. + * + * @return the a string + */ + public String getSomeString() { + return someString; + } + + /** + * Gets the test sub pojo. + * + * @return the test sub pojo + */ + public TestSubPojo getTestSubPojo() { + return testSubPojo; + } + +} diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojoList.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojoList.java new file mode 100644 index 000000000..0b39a30dc --- /dev/null +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestPojoList.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.service.engine.event.testpojos; + +import java.util.List; + +/** + * A test list of POJO for decoding and encoding. + */ +public class TestPojoList { + private List testPojoList; + + /** + * Gets the test pojo list. + * + * @return the test pojo list + */ + public List getTestPojoList() { + return testPojoList; + } +} diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubPojo.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubPojo.java new file mode 100644 index 000000000..f5ea80efc --- /dev/null +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubPojo.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.service.engine.event.testpojos; + +/** + * A test Pojo for pojo decoding and encoding in Apex. + */ +public class TestSubPojo { + private int anInt; + private Integer anInteger; + private String someString; + + private TestSubSubPojo testSubSubPojo; + + /** + * Gets the an int. + * + * @return the an int + */ + public int getAnInt() { + return anInt; + } + + /** + * Gets the an integer. + * + * @return the an integer + */ + public Integer getAnInteger() { + return anInteger; + } + + /** + * Gets the a string. + * + * @return the a string + */ + public String getSomeString() { + return someString; + } + + /** + * Gets the test sub sub pojo. + * + * @return the test sub sub pojo + */ + public TestSubSubPojo getTestSubSubPojo() { + return testSubSubPojo; + } + +} diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubSubPojo.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubSubPojo.java new file mode 100644 index 000000000..8e027f5d6 --- /dev/null +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/testpojos/TestSubSubPojo.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.service.engine.event.testpojos; + +/** + * A test Pojo for pojo decoding and encoding in Apex. + */ +public class TestSubSubPojo { + private int anInt; + private Integer anInteger; + private String someString; + + /** + * Gets the an int. + * + * @return the an int + */ + public int getAnInt() { + return anInt; + } + + /** + * Gets the an integer. + * + * @return the an integer + */ + public Integer getAnInteger() { + return anInteger; + } + + /** + * Gets the a string. + * + * @return the a string + */ + public String getSomeString() { + return someString; + } +} diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java index 7ae403726..8af9d57d9 100644 --- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java +++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/parameters/dummyclasses/SuperTokenDelimitedEventProtocolParameters.java @@ -20,7 +20,6 @@ package org.onap.policy.apex.service.engine.parameters.dummyclasses; -import org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin.JsonEventProtocolParameters; import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTokenDelimitedParameters; /** @@ -38,7 +37,7 @@ public class SuperTokenDelimitedEventProtocolParameters extends EventProtocolTex * the parameter service. */ public SuperTokenDelimitedEventProtocolParameters() { - super(JsonEventProtocolParameters.class.getCanonicalName()); + super(); // Set the event protocol properties for the JSON carrier technology this.setLabel(SUPER_TOKEN_EVENT_PROTOCOL_LABEL); -- cgit 1.2.3-korg