From a6557b0429dbe94a3806be237d9ba5aa7c4b183c Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Tue, 14 Feb 2017 19:49:32 -0500 Subject: Initial OpenECOMP policy/drools-applications commt Change-Id: I21c0edbf9b7f18dccd6bd4fe2a3287f3a68e6de0 Signed-off-by: Pamela Dragosh --- trafficgenerator/pom.xml | 46 +++++++++++++++++++ .../policy/vnf/trafficgenerator/PGRequest.java | 41 +++++++++++++++++ .../policy/vnf/trafficgenerator/PGStream.java | 42 +++++++++++++++++ .../policy/vnf/trafficgenerator/PGStreams.java | 42 +++++++++++++++++ .../vnf/trafficgenerator/util/Serialization.java | 32 +++++++++++++ .../policy/vnf/trafficgenerator/TestDemo.java | 52 ++++++++++++++++++++++ 6 files changed, 255 insertions(+) create mode 100644 trafficgenerator/pom.xml create mode 100644 trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGRequest.java create mode 100644 trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStream.java create mode 100644 trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStreams.java create mode 100644 trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/util/Serialization.java create mode 100644 trafficgenerator/src/test/java/org/openecomp/policy/vnf/trafficgenerator/TestDemo.java (limited to 'trafficgenerator') diff --git a/trafficgenerator/pom.xml b/trafficgenerator/pom.xml new file mode 100644 index 000000000..d8306c95d --- /dev/null +++ b/trafficgenerator/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + org.openecomp.policy.drools-applications + trafficgenerator + + + org.openecomp.policy.drools-applications + drools-pdp-apps + 1.0.0-SNAPSHOT + + + + + junit + junit + 4.12 + provided + + + com.google.code.gson + gson + 2.5 + provided + + + diff --git a/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGRequest.java b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGRequest.java new file mode 100644 index 000000000..b20a09bad --- /dev/null +++ b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGRequest.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.vnf.trafficgenerator; + +import java.io.Serializable; + + +import com.google.gson.annotations.SerializedName; + +public class PGRequest implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("pg-streams") + public PGStreams pgStreams; + + public PGRequest() { + } + +} diff --git a/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStream.java b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStream.java new file mode 100644 index 000000000..8f319624d --- /dev/null +++ b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStream.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.vnf.trafficgenerator; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class PGStream implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 5567635677419358210L; + + @SerializedName("id") + public String streamId; + @SerializedName("is-enabled") + public String isEnabled; + + public PGStream() { + } + +} diff --git a/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStreams.java b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStreams.java new file mode 100644 index 000000000..698254801 --- /dev/null +++ b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStreams.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.vnf.trafficgenerator; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class PGStreams implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 5567635677419358210L; + + @SerializedName("pg-stream") + public List pgStream= new LinkedList(); + + public PGStreams() { + } + +} diff --git a/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/util/Serialization.java b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/util/Serialization.java new file mode 100644 index 000000000..89816cdb3 --- /dev/null +++ b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/util/Serialization.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.vnf.trafficgenerator.util; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public final class Serialization { + + final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping() + .setPrettyPrinting() +// .registerTypeAdapter(AAIQueryParameters.class, new notificationTypeAdapter()) + .create(); +} diff --git a/trafficgenerator/src/test/java/org/openecomp/policy/vnf/trafficgenerator/TestDemo.java b/trafficgenerator/src/test/java/org/openecomp/policy/vnf/trafficgenerator/TestDemo.java new file mode 100644 index 000000000..705faf3be --- /dev/null +++ b/trafficgenerator/src/test/java/org/openecomp/policy/vnf/trafficgenerator/TestDemo.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.vnf.trafficgenerator; + + +import org.junit.Test; +//import org.openecomp.policy.aai.util.Serialization; +import org.openecomp.policy.vnf.trafficgenerator.PGRequest; +import org.openecomp.policy.vnf.trafficgenerator.PGStream; +import org.openecomp.policy.vnf.trafficgenerator.PGStreams; +import org.openecomp.policy.vnf.trafficgenerator.util.Serialization; + +public class TestDemo { + + @Test + public void test() { + PGRequest request = new PGRequest(); + request.pgStreams = new PGStreams(); + + PGStream pgStream; + for(int i = 0; i < 5; i++){ + pgStream = new PGStream(); + pgStream.streamId = "fw_udp"+(i+1); + pgStream.isEnabled = "true"; + request.pgStreams.pgStream.add(pgStream); + } + + String body = Serialization.gsonPretty.toJson(request); + System.out.println(body); + + // fail("Not yet implemented"); + } + +} -- cgit 1.2.3-korg