1616// under the License.
1717package org .apache .cloudstack .api .command .test ;
1818
19- import java .util .Arrays ;
20-
2119import junit .framework .Assert ;
2220import junit .framework .TestCase ;
2321
24- import org .junit .Before ;
25- import org .junit .Rule ;
26- import org .junit .Test ;
27- import org .junit .rules .ExpectedException ;
28- import org .mockito .Mockito ;
29-
3022import org .apache .cloudstack .api .ResponseGenerator ;
3123import org .apache .cloudstack .api .ServerApiException ;
3224import org .apache .cloudstack .api .command .admin .host .AddHostCmd ;
3325import org .apache .cloudstack .api .response .HostResponse ;
3426import org .apache .cloudstack .api .response .ListResponse ;
27+ import org .junit .Before ;
28+ import org .junit .Rule ;
29+ import org .junit .Test ;
30+ import org .junit .rules .ExpectedException ;
31+ import org .mockito .Mockito ;
3532
3633import com .cloud .exception .DiscoveryException ;
3734import com .cloud .exception .InvalidParameterValueException ;
3835import com .cloud .host .Host ;
3936import com .cloud .resource .ResourceService ;
4037
38+ import edu .emory .mathcs .backport .java .util .Arrays ;
39+
4140public class AddHostCmdTest extends TestCase {
4241
4342 private AddHostCmd addHostCmd ;
@@ -47,7 +46,6 @@ public class AddHostCmdTest extends TestCase {
4746 @ Rule
4847 public ExpectedException expectedException = ExpectedException .none ();
4948
50- @ Override
5149 @ Before
5250 public void setUp () {
5351 resourceService = Mockito .mock (ResourceService .class );
@@ -127,12 +125,14 @@ public void testExecuteForResult() throws Exception {
127125
128126 HostResponse responseHost = new HostResponse ();
129127 responseHost .setName ("Test" );
130- Mockito .doReturn (Arrays .asList (mockArray )).when (resourceService ).discoverHosts (addHostCmd );
131- Mockito .when (responseGenerator .createHostResponse (host )).thenReturn (responseHost );
128+ Mockito .when (resourceService .discoverHosts (addHostCmd )).thenReturn (
129+ Arrays .asList (mockArray ));
130+ Mockito .when (responseGenerator .createHostResponse (host )).thenReturn (
131+ responseHost );
132132 addHostCmd .execute ();
133133 Mockito .verify (responseGenerator ).createHostResponse (host );
134- @ SuppressWarnings ( "unchecked" )
135- ListResponse < HostResponse > actualResponse = (( ListResponse < HostResponse >) addHostCmd .getResponseObject ());
134+ ListResponse < HostResponse > actualResponse = (( ListResponse < HostResponse >) addHostCmd
135+ .getResponseObject ());
136136 Assert .assertEquals (responseHost , actualResponse .getResponses ().get (0 ));
137137 Assert .assertEquals ("addhostresponse" , actualResponse .getResponseName ());
138138
@@ -144,7 +144,8 @@ public void testExecuteForDiscoveryException() {
144144 addHostCmd ._resourceService = resourceService ;
145145
146146 try {
147- Mockito .when (resourceService .discoverHosts (addHostCmd )).thenThrow (DiscoveryException .class );
147+ Mockito .when (resourceService .discoverHosts (addHostCmd )).thenThrow (
148+ DiscoveryException .class );
148149 } catch (InvalidParameterValueException e ) {
149150 e .printStackTrace ();
150151 } catch (IllegalArgumentException e ) {
0 commit comments