Committed by
Gerrit Code Review
CORD Subscriber GUI - Added CDN function. Added backend boolean to filter out 'i…
…nternet' when talking to XOS. Change-Id: I076b9966c38589636968eef3dcaa203ba57f4eba
Showing
3 changed files
with
45 additions
and
8 deletions
... | @@ -59,11 +59,14 @@ public class XosManager { | ... | @@ -59,11 +59,14 @@ public class XosManager { |
59 | String uriFmt = subId(subscriberId) + "services/%s/%s"; | 59 | String uriFmt = subId(subscriberId) + "services/%s/%s"; |
60 | Set<XosFunctionDescriptor> inBundle = bundle.descriptor().functions(); | 60 | Set<XosFunctionDescriptor> inBundle = bundle.descriptor().functions(); |
61 | for (XosFunctionDescriptor xfd: XosFunctionDescriptor.values()) { | 61 | for (XosFunctionDescriptor xfd: XosFunctionDescriptor.values()) { |
62 | + // only process the functions that have a real back-end on XOS | ||
63 | + if (xfd.backend()) { | ||
62 | String uri = String.format(uriFmt, xfd.id(), inBundle.contains(xfd)); | 64 | String uri = String.format(uriFmt, xfd.id(), inBundle.contains(xfd)); |
63 | String result = xosUtils.putRest(uri); | 65 | String result = xosUtils.putRest(uri); |
64 | // TODO: convert JSON result to object and check (if we care) | 66 | // TODO: convert JSON result to object and check (if we care) |
65 | } | 67 | } |
66 | } | 68 | } |
69 | + } | ||
67 | 70 | ||
68 | /** | 71 | /** |
69 | * Configure XOS with new setting for given user and function, for the | 72 | * Configure XOS with new setting for given user and function, for the | ... | ... |
... | @@ -26,30 +26,45 @@ public enum XosFunctionDescriptor { | ... | @@ -26,30 +26,45 @@ public enum XosFunctionDescriptor { |
26 | */ | 26 | */ |
27 | INTERNET("internet", | 27 | INTERNET("internet", |
28 | "Internet", | 28 | "Internet", |
29 | - "Basic internet connectivity."), | 29 | + "Basic internet connectivity.", |
30 | + false), | ||
30 | 31 | ||
31 | /** | 32 | /** |
32 | * Firewall function. | 33 | * Firewall function. |
33 | */ | 34 | */ |
34 | FIREWALL("firewall", | 35 | FIREWALL("firewall", |
35 | "Firewall", | 36 | "Firewall", |
36 | - "Normal firewall protection."), | 37 | + "Normal firewall protection.", |
38 | + true), | ||
37 | 39 | ||
38 | /** | 40 | /** |
39 | * URL Filtering function (parental controls). | 41 | * URL Filtering function (parental controls). |
40 | */ | 42 | */ |
41 | URL_FILTER("url_filter", | 43 | URL_FILTER("url_filter", |
42 | "Parental Control", | 44 | "Parental Control", |
43 | - "Variable levels of URL filtering."); | 45 | + "Variable levels of URL filtering.", |
46 | + true), | ||
47 | + | ||
48 | + /** | ||
49 | + * Content Distribution function. | ||
50 | + */ | ||
51 | + CDN("cdn", | ||
52 | + "CDN", | ||
53 | + "Content Distribution Network service.", | ||
54 | + true); | ||
55 | + | ||
44 | 56 | ||
45 | private final String id; | 57 | private final String id; |
46 | private final String displayName; | 58 | private final String displayName; |
47 | private final String description; | 59 | private final String description; |
60 | + private final boolean backend; | ||
48 | 61 | ||
49 | - XosFunctionDescriptor(String id, String displayName, String description) { | 62 | + XosFunctionDescriptor(String id, String displayName, String description, |
63 | + boolean backend) { | ||
50 | this.id = id; | 64 | this.id = id; |
51 | this.displayName = displayName; | 65 | this.displayName = displayName; |
52 | this.description = description; | 66 | this.description = description; |
67 | + this.backend = backend; | ||
53 | } | 68 | } |
54 | 69 | ||
55 | /** | 70 | /** |
... | @@ -79,4 +94,13 @@ public enum XosFunctionDescriptor { | ... | @@ -79,4 +94,13 @@ public enum XosFunctionDescriptor { |
79 | return description; | 94 | return description; |
80 | } | 95 | } |
81 | 96 | ||
97 | + /** | ||
98 | + * Returns true if this function is supported by the XOS backend. | ||
99 | + * | ||
100 | + * @return true if backend function exists | ||
101 | + */ | ||
102 | + public boolean backend() { | ||
103 | + return backend; | ||
104 | + } | ||
105 | + | ||
82 | } | 106 | } | ... | ... |
... | @@ -19,8 +19,7 @@ package org.onosproject.cord.gui.model; | ... | @@ -19,8 +19,7 @@ package org.onosproject.cord.gui.model; |
19 | 19 | ||
20 | import org.junit.Test; | 20 | import org.junit.Test; |
21 | 21 | ||
22 | -import static org.junit.Assert.assertEquals; | 22 | +import static org.junit.Assert.*; |
23 | -import static org.junit.Assert.assertTrue; | ||
24 | import static org.onosproject.cord.gui.model.XosFunctionDescriptor.*; | 23 | import static org.onosproject.cord.gui.model.XosFunctionDescriptor.*; |
25 | 24 | ||
26 | /** | 25 | /** |
... | @@ -30,7 +29,7 @@ public class XosFunctionDescriptorTest { | ... | @@ -30,7 +29,7 @@ public class XosFunctionDescriptorTest { |
30 | 29 | ||
31 | @Test | 30 | @Test |
32 | public void numberOfFunctions() { | 31 | public void numberOfFunctions() { |
33 | - assertEquals("unexpected constant count", 3, values().length); | 32 | + assertEquals("unexpected constant count", 4, values().length); |
34 | } | 33 | } |
35 | 34 | ||
36 | @Test | 35 | @Test |
... | @@ -38,6 +37,7 @@ public class XosFunctionDescriptorTest { | ... | @@ -38,6 +37,7 @@ public class XosFunctionDescriptorTest { |
38 | assertEquals("wrong id", "internet", INTERNET.id()); | 37 | assertEquals("wrong id", "internet", INTERNET.id()); |
39 | assertEquals("wrong display", "Internet", INTERNET.displayName()); | 38 | assertEquals("wrong display", "Internet", INTERNET.displayName()); |
40 | assertTrue("wrong desc", INTERNET.description().startsWith("Basic")); | 39 | assertTrue("wrong desc", INTERNET.description().startsWith("Basic")); |
40 | + assertFalse("wrong backend", INTERNET.backend()); | ||
41 | } | 41 | } |
42 | 42 | ||
43 | @Test | 43 | @Test |
... | @@ -45,12 +45,22 @@ public class XosFunctionDescriptorTest { | ... | @@ -45,12 +45,22 @@ public class XosFunctionDescriptorTest { |
45 | assertEquals("wrong id", "firewall", FIREWALL.id()); | 45 | assertEquals("wrong id", "firewall", FIREWALL.id()); |
46 | assertEquals("wrong display", "Firewall", FIREWALL.displayName()); | 46 | assertEquals("wrong display", "Firewall", FIREWALL.displayName()); |
47 | assertTrue("wrong desc", FIREWALL.description().startsWith("Normal")); | 47 | assertTrue("wrong desc", FIREWALL.description().startsWith("Normal")); |
48 | + assertTrue("wrong backend", FIREWALL.backend()); | ||
48 | } | 49 | } |
49 | 50 | ||
50 | @Test | 51 | @Test |
51 | - public void urlFiltering() { | 52 | + public void urlFilter() { |
52 | assertEquals("wrong id", "url_filter", URL_FILTER.id()); | 53 | assertEquals("wrong id", "url_filter", URL_FILTER.id()); |
53 | assertEquals("wrong display", "Parental Control", URL_FILTER.displayName()); | 54 | assertEquals("wrong display", "Parental Control", URL_FILTER.displayName()); |
54 | assertTrue("wrong desc", URL_FILTER.description().startsWith("Variable")); | 55 | assertTrue("wrong desc", URL_FILTER.description().startsWith("Variable")); |
56 | + assertTrue("wrong backend", URL_FILTER.backend()); | ||
57 | + } | ||
58 | + | ||
59 | + @Test | ||
60 | + public void cdn() { | ||
61 | + assertEquals("wrong id", "cdn", CDN.id()); | ||
62 | + assertEquals("wrong display", "CDN", CDN.displayName()); | ||
63 | + assertTrue("wrong desc", CDN.description().startsWith("Content")); | ||
64 | + assertTrue("wrong backend", CDN.backend()); | ||
55 | } | 65 | } |
56 | } | 66 | } | ... | ... |
-
Please register or login to post a comment