所以我正在分配@RunWith(PowerMockRunner.class)
@PrepareForTest(TestService.class)
public class TestServiceTest {
@Mock
private TestService<Subscription> testServiceProxy;
@Mock
private Subscription subscription;
@Test
public void testStart() throws Exception {
Integer id = new Integer(5);
PowerMockito.mockStatic(TestService.class);
PowerMockito.when(TestService.getString()).thenReturn("Hello!");
PowerMockito.when(testServiceProxy.getInt()).thenReturn(new Integer(15));
PowerMockito.when(TestService.function1(Subscription.class,id)).thenReturn(testServiceProxy);
// PowerMockito.when(TestService.function1(Subscription.class,Matchers.eq(any(Integer.class)))).thenReturn(testServiceProxy);
System.out.println("String: " + TestService.getString());
System.out.println("TestServiceProxy: "+testServiceProxy);
// id = new Integer(6);
System.out.println("Function1: "+TestService.function1(Subscription.class, id));
TestService<Subscription> foo = TestService.function1(Subscription.class, id);
if (foo != null) {
System.out.println(" foo instrumentId: "+foo.getInt());
System.out.println(" subselect instrumentId: "+testServiceProxy.getInt());
} else {
System.out.println("Foo is null");
}
}
}
。但是在调试时我发现我的矩阵有[0,0] [0,1]。(插槽)为什么会这样?我有2个值的插槽?不应该只有1吗? (别告诉我,我必须使用一维数组,这只是一个例子)。如果我想声明一个3乘2的矩阵(只有3个可能的行)[0,0],[0,1],[0,2]我应该怎么做?