checkstyle: TypeName
[neutron.git] / neutron-spi / src / test / java / org / opendaylight / neutron / spi / NeutronLoadBalancerPoolJAXBTest.java
1 /*
2  * Copyright (c) 2015 Tata Consultancy Services.  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 java.util.List;
12 import javax.xml.bind.JAXBException;
13 import org.junit.Assert;
14 import org.junit.Test;
15
16 public class NeutronLoadBalancerPoolJAXBTest {
17
18     private static final String NEUTRON_LOAD_BALANCER_POOL_SOURCE_JSON = "{ " + "\"admin_state_up\": true, "
19             + "\"description\": \"simple pool\", " + "\"healthmonitor_id\": \"00066a7b-796b-4f26-9cf9-9e82d248fda7\", "
20             + "\"id\": \"12ff63af-4127-4074-a251-bcb2ecc53ebe\", " + "\"lb_algorithm\": \"ROUND_ROBIN\", "
21             + "\"listeners\": [ " + "{ " + "\"id\": \"39de4d56-d663-46e5-85a1-5b9d5fa17829\" " + "} " + "], "
22             + "\"members\": [], " + "\"name\": \"pool1\", " + "\"protocol\": \"HTTP\", " + "\"session_persistence\": { "
23             + "\"cookie_name\": \"my_cookie\", " + "\"type\": \"APP_COOKIE\" " + "}, "
24             + "\"tenant_id\": \"1a3e005cf9ce40308c900bcb08e5320c\" " + "} ";
25
26     @Test
27     public void test_NeutronLoadBalancerPool_JAXB()  throws JAXBException {
28         NeutronLoadBalancerPool dummyObject = new NeutronLoadBalancerPool();
29
30         NeutronLoadBalancerPool testObject = (NeutronLoadBalancerPool) JaxbTestHelper.jaxbUnmarshall(dummyObject,
31                 NEUTRON_LOAD_BALANCER_POOL_SOURCE_JSON);
32         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 1: Testing id failed",
33                 "12ff63af-4127-4074-a251-bcb2ecc53ebe", testObject.getID());
34
35         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 2: Testing name failed", "pool1",
36                 testObject.getName());
37
38         Assert.assertTrue("NeutronLoadBalancerPool JAXB Test 3: Testing admin_state_up failed",
39                 testObject.getLoadBalancerPoolAdminIsStateIsUp());
40
41         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 5: Testing LbAlgorithm failed", "ROUND_ROBIN",
42                 testObject.getLoadBalancerPoolLbAlgorithm());
43
44         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 6: Testing Protocol failed", "HTTP",
45                 testObject.getLoadBalancerPoolProtocol());
46
47         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 7: Testing Tenant_id failed",
48                 "1a3e005cf9ce40308c900bcb08e5320c", testObject.getTenantID());
49
50         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 8: Testing HealthMonitorID failed",
51                 "00066a7b-796b-4f26-9cf9-9e82d248fda7", testObject.getNeutronLoadBalancerPoolHealthMonitorID());
52
53         List<NeutronID> testListeners = testObject.getLoadBalancerPoolListeners();
54         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 9.1: Testing Listeners failed", 1,
55                 testListeners.size());
56
57         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 9.2: Testing Listeners failed",
58                 "39de4d56-d663-46e5-85a1-5b9d5fa17829", testObject.getLoadBalancerPoolListeners().get(0).getID());
59
60         List<NeutronLoadBalancerPoolMember> testMembers = testObject.getLoadBalancerPoolMembers();
61         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 10.1: Testing Listeners failed", 0,
62                 testMembers.size());
63
64         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 11: Testing session_persistence cookie_name failed",
65                 "my_cookie", testObject.getLoadBalancerPoolSessionPersistence().getCookieName());
66
67         Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 12: Testing session_persistence type failed",
68                 "APP_COOKIE", testObject.getLoadBalancerPoolSessionPersistence().getType());
69     }
70 }