Allocate Rule
[holmes/rule-management.git] / rulemgt / src / test / java / org / onap / holmes / rulemgt / send / RuleAllocationTest.java
1 /**
2 * Copyright 2017 ZTE Corporation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.onap.holmes.rulemgt.send;
18
19
20 import org.junit.Test;
21 import org.powermock.api.easymock.PowerMock;
22 import org.powermock.reflect.Whitebox;
23
24 import java.util.ArrayList;
25 import java.util.List;
26
27 import static org.hamcrest.core.IsEqual.equalTo;
28 import static org.junit.Assert.assertThat;
29
30 public class RuleAllocationTest {
31
32     private RuleAllocation ruleAllocation = new RuleAllocation();
33     @Test
34     public void extendCompareIpTest() throws Exception{
35         List<String> newList = new ArrayList<>();
36         newList.add("10.96.33.34");
37         newList.add("10.74.65.24");
38
39         List<String> oldList = new ArrayList<>();
40         oldList.add("10.96.33.34");
41         List<String> extendIp = Whitebox.invokeMethod(ruleAllocation,"extendCompareIp",newList,oldList);
42
43         PowerMock.verifyAll();
44
45         assertThat(extendIp.get(0),equalTo("10.74.65.24"));
46     }
47
48     @Test
49     public void destroyCompareIpTest() throws Exception{
50         List<String> newList = new ArrayList<>();
51         newList.add("10.96.33.34");
52
53         List<String> oldList = new ArrayList<>();
54         oldList.add("10.96.33.34");
55         oldList.add("10.74.65.24");
56         List<String> destoryIp = Whitebox.invokeMethod(ruleAllocation,"destroyCompareIp",newList,oldList);
57
58         PowerMock.verifyAll();
59
60         assertThat(destoryIp.get(0),equalTo("10.74.65.24"));
61     }
62
63 }