Fix more copyright citations
[neutron.git] / neutron-spi / src / test / java / org / opendaylight / neutron / spi / NeutronSecurityGroupJAXBTest.java
1 /*
2  * Copyright Tata Consultancy Services, 2015.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.neutron.spi;
10
11 import static org.junit.Assert.*;
12
13 import java.util.List;
14
15 import org.junit.Assert;
16 import org.junit.Test;
17
18 public class NeutronSecurityGroupJAXBTest {
19     private static final String NeutronSecurityGroup_sourceJson = "{" +
20         "\"id\": \"2076db17-a522-4506-91de-c6dd8e837028\", " +
21         "\"name\": \"new-webservers\", " +
22         "\"description\": \"security group for webservers\", " +
23         "\"tenant_id\": \"b4f50856753b4dc6afee5fa6b9b6c550\", " +
24         "\"security_group_rules\": [ { \"id\": \"2bc0accf-312e-429a-956e-e4407625eb62\" , " +
25                                        "\"direction\": \"ingress\" , " +
26                                        "\"protocol\": \"tcp\" , " +
27                                        "\"port_range_min\": 80 , " +
28                                        "\"port_range_max\": 80 , " +
29                                        "\"ethertype\": \"IPv4\" ," +
30                                        "\"remote_ip_prefix\": \"0.0.0.0/0\" , " +
31                                        "\"remote_group_id\": \"85cc3048-abc3-43cc-89b3-377341426ac5\" , " +
32                                        "\"security_group_id\": \"a7734e61-b545-452d-a3cd-0189cbd9747a\" , " +
33                                        "\"tenant_id\": \"e4f50856753b4dc6afee5fa6b9b6c550\" } ]" +
34         "}";
35     @Test
36     public void test_NeutronSecurityGroup_JAXB() {
37         NeutronSecurityGroup dummyObject = new NeutronSecurityGroup();
38         try {
39             NeutronSecurityGroup testObject = (NeutronSecurityGroup) JaxbTestHelper.jaxbUnmarshall(dummyObject, NeutronSecurityGroup_sourceJson);
40             List<NeutronSecurityRule> securityRules = testObject.getSecurityRules();
41             Assert.assertEquals("NeutronSecurityGroup JAXB Test 1: Testing id failed",
42                   "2076db17-a522-4506-91de-c6dd8e837028", testObject.getSecurityGroupUUID());
43
44             Assert.assertEquals("NeutronSecurityGroup JAXB Test 2: Testing direction failed",
45                   "new-webservers", testObject.getSecurityGroupName());
46
47             Assert.assertEquals("NeutronSecurityGroup JAXB Test 3: Testing protocol failed",
48                   "security group for webservers", testObject.getSecurityGroupDescription());
49
50             Assert.assertEquals("NeutronSecurityGroup JAXB Test 4: Testing port range min failed",
51                     "b4f50856753b4dc6afee5fa6b9b6c550", testObject.getSecurityGroupTenantID());
52
53             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.1: Testing security group rules list length failed",
54                     1, securityRules.size());
55             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.2: Testing security group rules id value failed",
56                     "2bc0accf-312e-429a-956e-e4407625eb62", securityRules.get(0).securityRuleUUID);
57             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.3: Testing security group rules direction value failed",
58                     "ingress", securityRules.get(0).securityRuleDirection);
59             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.4: Testing security group rules protocol value failed",
60                     "tcp", securityRules.get(0).securityRuleProtocol);
61             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.5: Testing security group rules port range min value failed",
62                     new Integer(80), securityRules.get(0).securityRulePortMin);
63             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.6: Testing security group rules port range max value failed",
64                     new Integer(80), securityRules.get(0).securityRulePortMax);
65             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.7: Testing security group rules ethertype value failed",
66                     "IPv4", securityRules.get(0).securityRuleEthertype);
67             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.8: Testing security group rules remote ip prefix value failed",
68                     "0.0.0.0/0", securityRules.get(0).securityRuleRemoteIpPrefix);
69             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.9: Testing security group rules remote group id value failed",
70                     "85cc3048-abc3-43cc-89b3-377341426ac5", securityRules.get(0).securityRemoteGroupID);
71             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.10: Testing security group rules security group id value failed",
72                     "a7734e61-b545-452d-a3cd-0189cbd9747a", securityRules.get(0).securityRuleGroupID);
73             Assert.assertEquals("NeutronSecurityGroup JAXB Test 5.11: Testing security group rules tenant id value failed",
74                     "e4f50856753b4dc6afee5fa6b9b6c550", securityRules.get(0).securityRuleTenantID);
75         } catch (Exception e) {
76             Assert.fail("Tests failed");
77         }
78     }
79 }