aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Brady <patrick.brady@att.com>2019-05-13 16:16:58 -0700
committerPatrick Brady <patrick.brady@att.com>2019-05-13 23:29:04 -0700
commit25f856faedd92ba62e8348507f7baf8ef34f4540 (patch)
treee28f00b06d463808aebc1dbb9f2323d72ef68023
parentc3719d87ad36bd1fae457f34ec8aa3247915dc6f (diff)
Update message format for vFirewall
The message format coming from policy has changed. This is the corresponding update for appc to match the message format. Change-Id: I8827e6c372be77dc69c0ee3579a002fde2515848 Signed-off-by: Patrick Brady <patrick.brady@att.com> Issue-ID: APPC-1603
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ProviderOperations.java2
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/CommonMessage.java60
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/AbstractListenerTest.java1
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/demo/model/TestCommonMessage.java12
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/demo/model/TestMessages.java17
5 files changed, 26 insertions, 66 deletions
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ProviderOperations.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ProviderOperations.java
index 85de6bd66..f51be2859 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ProviderOperations.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ProviderOperations.java
@@ -89,7 +89,7 @@ public class ProviderOperations {
}
//String body = buildReqest(msg.getId(), msg.getUrl(), msg.getIdentityUrl());
- String body = buildReqest(msg.getHeader().getRequestID(), msg.getPayload().getGenericVnfId(), msg.getPayload().getPgStreams());
+ String body = buildReqest(msg.getHeader().getRequestID(), msg.getPayload().getGenericVnfId(), msg.getPayload().getStreams());
StringEntity entity = new StringEntity(body);
entity.setContentType("application/json");
post.setEntity(new StringEntity(body));
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/CommonMessage.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/CommonMessage.java
index 45b99a9f6..e0dbbab67 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/CommonMessage.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/CommonMessage.java
@@ -268,25 +268,16 @@ public class CommonMessage implements Serializable {
this.genericVnfId = genericVnfId;
}
- @JsonProperty("pg-streams")
- private pgStreams pgStreams;
+ @JsonProperty("streams")
+ private Streams streams;
/**
* @return the TenantID
*/
- public String getPgStreams() {
- String r = "{\\\"pg-streams\\\": {\\\"pg-stream\\\":[";
- boolean first = true;
- for(pgStream p : this.pgStreams.streams){
- String n = "{\\\"id\\\":\\\""+p.getId()+"\\\", \\\"is-enabled\\\":\\\""+p.getIsEnabled()+"\\\"}";
- if(!first){
- r = r.concat(",");
- }
- first = false;
- r = r.concat(n);
- }
- r= r.concat("]}}");
+ public String getStreams() {
+ String r = "{\\\"streams\\\": {\\\"active-streams\\\": " + streams.getActiveStreams() +
+ "}}";
return r;
}
@@ -294,8 +285,8 @@ public class CommonMessage implements Serializable {
* @param TenantID
* the TenantID to set
*/
- public void setPgStreams(pgStreams pgStreams) {
- this.pgStreams = pgStreams;
+ public void setStreams(Streams streams) {
+ this.streams = streams;
}
@@ -304,36 +295,19 @@ public class CommonMessage implements Serializable {
};
@JsonIgnoreProperties(ignoreUnknown = true)
- public static class pgStreams {
- @JsonProperty("pg-stream")
- private Collection<pgStream> streams;
-
- public Collection<pgStream> getStreams() {
- return streams;
+ public static class Streams {
+
+ @JsonProperty("active-streams")
+ private int activeStreams;
+
+ public int getActiveStreams() {
+ return this.activeStreams;
}
- public void setStreams(Collection<pgStream> streams) {
- this.streams = streams;
+ public void setActiveStreams(int activeStreams) {
+ this.activeStreams = activeStreams;
}
+
};
- @JsonIgnoreProperties(ignoreUnknown = true)
- public static class pgStream{
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getIsEnabled() {
- return isEnabled;
- }
- public void setIsEnabled(String isEnabled) {
- this.isEnabled = isEnabled;
- }
- @JsonProperty("id")
- private String id;
- @JsonProperty("is-enabled")
- private String isEnabled;
- };
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/AbstractListenerTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/AbstractListenerTest.java
index 1b37f452d..a47175c02 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/AbstractListenerTest.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/AbstractListenerTest.java
@@ -42,7 +42,6 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.appc.listener.AbstractListener;
import org.onap.appc.listener.ListenerProperties;
-import sun.awt.windows.ThemeReader;
public class AbstractListenerTest {
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/demo/model/TestCommonMessage.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/demo/model/TestCommonMessage.java
index ebc2706cd..341492f26 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/demo/model/TestCommonMessage.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/demo/model/TestCommonMessage.java
@@ -30,17 +30,16 @@ import java.util.Collection;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
-import org.onap.appc.listener.demo.model.CommonMessage.pgStream;
public class TestCommonMessage {
private CommonMessage commonMessage;
- private CommonMessage.pgStreams pgStreams;
+ private CommonMessage.Payload payload;
@Before
public void setUp() {
commonMessage = new CommonMessage();
- pgStreams = new CommonMessage.pgStreams();
+ payload = new CommonMessage.Payload();
}
@Test
@@ -48,11 +47,4 @@ public class TestCommonMessage {
assertTrue(commonMessage.toJson() instanceof JSONObject);
}
- @Test
- public void testStreams() {
- Collection<pgStream> streams = new ArrayList<>();
- pgStreams.setStreams(streams);
- assertSame(streams, pgStreams.getStreams());
- }
-
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/demo/model/TestMessages.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/demo/model/TestMessages.java
index 62ea83a2d..9cce23d95 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/demo/model/TestMessages.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/demo/model/TestMessages.java
@@ -39,7 +39,7 @@ import org.json.JSONObject;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-import org.onap.appc.listener.demo.model.CommonMessage.pgStream;
+import org.onap.appc.listener.demo.model.CommonMessage.Streams;
import org.onap.appc.listener.demo.model.IncomingMessage;
import org.onap.appc.listener.demo.model.OutgoingMessage;
import org.onap.appc.listener.demo.model.Status;
@@ -117,18 +117,13 @@ public class TestMessages {
public void testPayload() {
CommonMessage.Payload payload = new CommonMessage.Payload();
payload.setGenericVnfId("VNF_ID");
- CommonMessage.pgStream pgStream = new CommonMessage.pgStream();
- pgStream.setId("ID");
- pgStream.setIsEnabled("true");
- CommonMessage.pgStreams pgStreams = new CommonMessage.pgStreams();
- Collection<pgStream> collectionPgStreams = new ArrayList<pgStream>();
- collectionPgStreams.add(pgStream);
- pgStreams.setStreams(collectionPgStreams);
- payload.setPgStreams(pgStreams);
+ CommonMessage.Streams streams = new CommonMessage.Streams();
+ streams.setActiveStreams(7);
+ payload.setStreams(streams);
in.setPayload(payload);
assertEquals("VNF_ID", in.getPayload().getGenericVnfId());
- assertEquals("{\\\"pg-streams\\\": {\\\"pg-stream\\\":[{\\\"id\\\":\\\"ID\\\", \\\"is-enabled\\\":\\\"true\\\"}]}}",
- in.getPayload().getPgStreams());
+ assertEquals("{\\\"streams\\\": {\\\"active-streams\\\": 7}}",
+ in.getPayload().getStreams());
}
@Test