如何在此模拟对象中设置值

时间:2015-07-15 09:43:38

标签: java mockito

如何在下面的模拟对象中设置值。 我知道如何获取值但是如何使用mock设置值?

    public class AUTest
    {

    Set<String> permissionIds = new HashSet<String>();

    @Mock 
    UserService userservice;

    @Mock
    PermissionService permissionservice;

    Set<String> emailid = new HashSet<String>();


    @Test
    public void getSuperUserPermissions()
    {
        List<Permissions> allPermissions = permissionservice.getAllPermissions();
        PermissionService permission = Mockito.mock(PermissionService.class);
        Mockito.when(permission.getPermissionById(5L)).thenReturn(pemission);
        Assert.assertNotNull(allPermissions);
    }

}

0 个答案:

没有答案