CORD Subscriber GUI - Added levels OFF, G, and NONE to UrlFilterFunction.Level enum.
- added some unit tests for UrlFilterFunction.
Change-Id: Ic241818e260b84541665031e659c87f61f8899cf
diff --git a/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/CoreModelCacheTest.java b/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/CoreModelCacheTest.java
index 373f2e4..746d145 100644
--- a/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/CoreModelCacheTest.java
+++ b/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/CoreModelCacheTest.java
@@ -95,7 +95,7 @@
public void setNewLevel() {
cache.setCurrentBundle("family");
JsonNode node = fromString(cache.jsonUsers());
- assertEquals("wrong level", "PG", getMomsLevel(node));
+ assertEquals("wrong level", "G", getMomsLevel(node));
cache.applyPerUserParam("1", "url_filter", "level", "R");
@@ -191,11 +191,14 @@
" \"name\": \"Parental Control\",\n" +
" \"desc\": \"Variable levels of URL filtering.\",\n" +
" \"params\": {\n" +
- " \"level\": \"PG\",\n" +
+ " \"level\": \"G\",\n" +
" \"levels\": [\n" +
+ " \"OFF\",\n" +
+ " \"G\",\n" +
" \"PG\",\n" +
" \"PG_13\",\n" +
- " \"R\"\n" +
+ " \"R\",\n" +
+ " \"NONE\"\n" +
" ]\n" +
" }\n" +
" }\n" +
@@ -252,7 +255,7 @@
" \"mac\": \"010203040506\",\n" +
" \"profile\": {\n" +
" \"url_filter\": {\n" +
- " \"level\": \"PG\"\n" +
+ " \"level\": \"G\"\n" +
" }\n" +
" }\n" +
" },\n" +
@@ -262,7 +265,7 @@
" \"mac\": \"010203040507\",\n" +
" \"profile\": {\n" +
" \"url_filter\": {\n" +
- " \"level\": \"PG\"\n" +
+ " \"level\": \"G\"\n" +
" }\n" +
" }\n" +
" },\n" +
@@ -272,7 +275,7 @@
" \"mac\": \"010203040508\",\n" +
" \"profile\": {\n" +
" \"url_filter\": {\n" +
- " \"level\": \"PG\"\n" +
+ " \"level\": \"G\"\n" +
" }\n" +
" }\n" +
" },\n" +
@@ -282,7 +285,7 @@
" \"mac\": \"010203040509\",\n" +
" \"profile\": {\n" +
" \"url_filter\": {\n" +
- " \"level\": \"PG\"\n" +
+ " \"level\": \"G\"\n" +
" }\n" +
" }\n" +
" }\n" +
diff --git a/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/model/UrlFilterFunctionTest.java b/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/model/UrlFilterFunctionTest.java
new file mode 100644
index 0000000..6bc75de
--- /dev/null
+++ b/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/model/UrlFilterFunctionTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.
+ *
+ */
+
+package org.onosproject.cord.gui.model;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Unit tests for {@link UrlFilterFunction}.
+ */
+public class UrlFilterFunctionTest {
+
+ private SubscriberUser user = new SubscriberUser(1, "foo", "fooMAC");
+ private UrlFilterFunction fn;
+
+ @Before
+ public void setUp() {
+ fn = new UrlFilterFunction();
+ }
+
+ @Test
+ public void basic() {
+ assertEquals("wrong enum const count",
+ 6, UrlFilterFunction.Level.values().length);
+ }
+
+ @Test
+ public void memento() {
+ XosFunction.Memento memo = fn.createMemento();
+ assertTrue("wrong class", memo instanceof UrlFilterFunction.UrlFilterMemento);
+ UrlFilterFunction.UrlFilterMemento umemo =
+ (UrlFilterFunction.UrlFilterMemento) memo;
+ assertEquals("wrong default level", "G", umemo.level());
+ }
+
+ @Test
+ public void memoNewLevel() {
+ XosFunction.Memento memo = fn.createMemento();
+ assertTrue("wrong class", memo instanceof UrlFilterFunction.UrlFilterMemento);
+ UrlFilterFunction.UrlFilterMemento umemo =
+ (UrlFilterFunction.UrlFilterMemento) memo;
+ assertEquals("wrong default level", "G", umemo.level());
+ umemo.setLevel(UrlFilterFunction.Level.R);
+ assertEquals("wrong new level", "R", umemo.level());
+ }
+
+ @Test
+ public void applyMemo() {
+ UrlFilterFunction.UrlFilterMemento memo =
+ (UrlFilterFunction.UrlFilterMemento) fn.createMemento();
+ memo.setLevel(UrlFilterFunction.Level.PG_13);
+ user.setMemento(XosFunctionDescriptor.URL_FILTER, memo);
+
+ assertEquals("wrong URL suffix", "url_filter/PG_13", fn.xosUrlApply(user));
+ }
+}