Neutron Model update
[neutron.git] / integration / test / src / test / java / org / opendaylight / neutron / e2etest / NeutronRevisionNumberTests.java
1 /*
2  * Copyright (C) 2017 Intel, Corp.
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.e2etest;
10
11 public class NeutronRevisionNumberTests {
12
13     String base;
14
15     public NeutronRevisionNumberTests(String base) {
16         this.base = base;
17     }
18
19     public void subnet_create_test() {
20         String url = base + "/subnets";
21         String content = " { \"subnets\": [ " + " { \"allocation_pools\": [ "
22                 + " { \"end\": \"192.168.199.254\", \"start\": \"192.168.199.2\" } ], "
23                 + " \"cidr\": \"192.168.199.0/24\", " + " \"dns_nameservers\": [\"8.8.8.8\"], "
24                 + " \"enable_dhcp\": true, " + " \"gateway_ip\": \"192.168.199.1\", "
25                 + " \"host_routes\":[ { \"destination\":\"0.0.0.0/0\", " + " \"nexthop\":\"192.168.199.3\" }, "
26                 + " { \"destination\":\"192.168.0.0/24\", " + " \"nexthop\":\"192.168.199.4\" } ], "
27                 + " \"id\": \"1468a7a7-290d-4127-aedd-6c9449775a24\", " + " \"ip_version\": 4, " + " \"name\": \"\", "
28                 + " \"network_id\": \"af374017-c9ae-4a1d-b799-ab73111476e2\", "
29                 + " \"tenant_id\": \"4fd44f30292945e481c7b8a0c8908869\" }, { "
30                 + " \"allocation_pools\": [ { \"end\": \"10.56.7.254\", \"start\": \"10.56.4.2\" } ], "
31                 + " \"cidr\": \"10.56.4.0/22\", " + " \"dns_nameservers\": [\"8.8.8.8\", \"8.8.8.4\"], "
32                 + " \"enable_dhcp\": true, " + " \"gateway_ip\": \"10.56.4.1\", "
33                 + " \"host_routes\":[ { \"destination\":\"0.0.0.0/0\", " + " \"nexthop\":\"10.56.4.3\" }, "
34                 + " { \"destination\":\"192.168.0.0/24\", " + " \"nexthop\":\"10.56.4.4\" } ], "
35                 + " \"id\": \"c0e7435c-1512-45fb-aa9e-9a7c5932fb30\", " + " \"ip_version\": 4, " + " \"name\": \"\", "
36                 + " \"network_id\": \"af374017-c9ae-4a1d-b799-ab73111476e2\", "
37                 + " \"tenant_id\": \"4fd44f30292945e481c7b8a0c8908869\" } ] }";
38         ITNeutronE2E.test_create(url, content, "Revision Number Post Failed");
39     }
40
41     public void subnet_update_test() {
42         String url = base + "/subnets/c0e7435c-1512-45fb-aa9e-9a7c5932fb30";
43         String content = " { \"subnet\": { " + " \"name\": \"my_subnet\", " + " \"enable_dhcp\": true, "
44                 + " \"network_id\": \"af374017-c9ae-4a1d-b799-ab73111476e2\", "
45                 + " \"tenant_id\": \"4fd44f30292945e481c7b8a0c8908869\", "
46                 + " \"dns_nameservers\": [\"8.8.8.8\", \"8.8.8.4\"], "
47                 + " \"allocation_pools\": [ { \"start\": \"10.0.0.2\", \"end\": \"10.0.0.254\" } ], "
48                 + " \"host_routes\": [{ \"destination\":\"192.168.0.0/24\", " + " \"nexthop\":\"10.0.0.11\" } ], "
49                 + " \"ip_version\": 4, " + " \"gateway_ip\": \"10.0.0.1\", " + " \"cidr\": \"10.0.0.0/24\", "
50                 + "\"revision_number\": 3, "
51                 + " \"id\": \"c0e7435c-1512-45fb-aa9e-9a7c5932fb30\" } }";
52         ITNeutronE2E.test_modify(url, content, "Revision Number Put Failed");
53     }
54
55     public void subnet_update_test_with_old_value() {
56         String url = base + "/subnets/c0e7435c-1512-45fb-aa9e-9a7c5932fb30";
57         String content = " { \"subnet\": { " + " \"name\": \"my_subnet\", " + " \"enable_dhcp\": true, "
58                 + " \"network_id\": \"af374017-c9ae-4a1d-b799-ab73111476e2\", "
59                 + " \"tenant_id\": \"4fd44f30292945e481c7b8a0c8908869\", "
60                 + " \"dns_nameservers\": [\"8.8.8.8\", \"8.8.8.4\"], "
61                 + " \"allocation_pools\": [ { \"start\": \"10.0.0.2\", \"end\": \"10.0.0.254\" } ], "
62                 + " \"host_routes\": [{ \"destination\":\"192.168.0.0/24\", " + " \"nexthop\":\"10.0.0.11\" } ], "
63                 + " \"ip_version\": 4, " + " \"gateway_ip\": \"10.0.0.1\", " + " \"cidr\": \"10.0.0.0/24\", "
64                 + "\"revision_number\": 2, "
65                 + " \"id\": \"c0e7435c-1512-45fb-aa9e-9a7c5932fb30\" } }";
66         ITNeutronE2E.test_modify(url, content, "Revision Number Put Failed");
67     }
68
69     public void subnet_update_test_with_no_value() {
70         String url = base + "/subnets/c0e7435c-1512-45fb-aa9e-9a7c5932fb30";
71         String content = " { \"subnet\": { " + " \"name\": \"my_subnet\", " + " \"enable_dhcp\": true, "
72                 + " \"network_id\": \"af374017-c9ae-4a1d-b799-ab73111476e2\", "
73                 + " \"tenant_id\": \"4fd44f30292945e481c7b8a0c8908869\", "
74                 + " \"dns_nameservers\": [\"8.8.8.8\", \"8.8.8.4\"], "
75                 + " \"allocation_pools\": [ { \"start\": \"10.0.0.2\", \"end\": \"10.0.0.254\" } ], "
76                 + " \"host_routes\": [{ \"destination\":\"192.168.0.0/24\", " + " \"nexthop\":\"10.0.0.11\" } ], "
77                 + " \"ip_version\": 4, " + " \"gateway_ip\": \"10.0.0.1\", " + " \"cidr\": \"10.0.0.0/24\", "
78                 + " \"id\": \"c0e7435c-1512-45fb-aa9e-9a7c5932fb30\" } }";
79         ITNeutronE2E.test_modify(url, content, "Revision Number Put Failed");
80     }
81
82     public void subnet_element_get_test() {
83         String url = base + "/subnets/c0e7435c-1512-45fb-aa9e-9a7c5932fb30";
84         ITNeutronE2E.test_fetch(url, true, "Revision Number Element Get Failed");
85     }
86
87     public void subnet_delete_test() {
88         String url = base + "/subnets/c0e7435c-1512-45fb-aa9e-9a7c5932fb30";
89         ITNeutronE2E.test_delete(url, "Revision Number Element Delete Failed");
90     }
91
92     public static void runTests(String base) {
93         NeutronRevisionNumberTests tester = new NeutronRevisionNumberTests(base);
94         tester.subnet_create_test();
95         tester.subnet_element_get_test();
96         tester.subnet_update_test();
97         tester.subnet_update_test_with_old_value();
98         tester.subnet_update_test_with_no_value();
99         tester.subnet_delete_test();
100     }
101 }