Fix star import and enable checkstyle rule to prevent it.
[controller.git] / opendaylight / netconf / config-netconf-connector / src / test / java / org / opendaylight / controller / netconf / confignetconfconnector / operations / editconfig / ReplaceEditConfigStrategyTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.controller.netconf.confignetconfconnector.operations.editconfig;
10
11 import com.google.common.collect.Sets;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.mockito.Mock;
15 import org.mockito.MockitoAnnotations;
16 import org.opendaylight.controller.config.util.ConfigTransactionClient;
17 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeConfigElement;
18
19 import javax.management.Attribute;
20 import javax.management.ObjectName;
21 import java.util.Map;
22
23 import static org.mockito.Matchers.any;
24 import static org.mockito.Matchers.anyString;
25 import static org.mockito.Mockito.doNothing;
26 import static org.mockito.Mockito.doReturn;
27 import static org.mockito.Mockito.mock;
28 import static org.mockito.Mockito.verify;
29
30 public class ReplaceEditConfigStrategyTest {
31
32     @Mock
33     private ConfigTransactionClient ta;
34
35     @Before
36     public void setUp() throws Exception {
37         MockitoAnnotations.initMocks(this);
38         doNothing().when(ta).destroyConfigBean(anyString(), anyString());
39         doReturn(mockON()).when(ta).lookupConfigBean(anyString(), anyString());
40         doNothing().when(ta).setAttribute(any(ObjectName.class), anyString(), any(Attribute.class));
41     }
42
43     @Test
44     public void test() throws Exception {
45         ReplaceEditConfigStrategy strat = new ReplaceEditConfigStrategy();
46
47         Map<String, AttributeConfigElement> map = EditConfigTest.getSimpleAttributes();
48
49         doReturn(Sets.newHashSet(mockON(), mockON())).when(ta).lookupConfigBeans();
50
51         strat.executeConfiguration("m1", "i1", map, ta);
52
53         verify(ta).lookupConfigBean(anyString(), anyString());
54         verify(ta).setAttribute(any(ObjectName.class), anyString(), any(Attribute.class));
55     }
56
57     ObjectName mockON() {
58         ObjectName mock = mock(ObjectName.class);
59         doReturn("mockON").when(mock).toString();
60         return mock;
61     }
62
63 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.