Search in sources :

Example 1 with SimpleVarArgsConstructorDemo

use of samples.expectnew.SimpleVarArgsConstructorDemo in project powermock by powermock.

the class WhenNewCases method testNewWithArrayVarArgsWhenAllArgumentsAreNull.

@Test
public void testNewWithArrayVarArgsWhenAllArgumentsAreNull() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();
    SimpleVarArgsConstructorDemo varArgsConstructorDemoMock = mock(SimpleVarArgsConstructorDemo.class);
    final byte[] byteArrayOne = null;
    final byte[] byteArrayTwo = null;
    whenNew(SimpleVarArgsConstructorDemo.class).withArguments(byteArrayOne, byteArrayTwo).thenReturn(varArgsConstructorDemoMock);
    when(varArgsConstructorDemoMock.getByteArrays()).thenReturn(new byte[][] { byteArrayTwo });
    byte[][] varArgs = tested.newSimpleVarArgs(byteArrayOne, byteArrayTwo);
    assertEquals(1, varArgs.length);
    assertSame(byteArrayTwo, varArgs[0]);
    verifyNew(SimpleVarArgsConstructorDemo.class).withArguments(byteArrayOne, byteArrayTwo);
}
Also used : ExpectNewDemo(samples.expectnew.ExpectNewDemo) SimpleVarArgsConstructorDemo(samples.expectnew.SimpleVarArgsConstructorDemo) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 ExpectNewDemo (samples.expectnew.ExpectNewDemo)1 SimpleVarArgsConstructorDemo (samples.expectnew.SimpleVarArgsConstructorDemo)1