### Question:
UserContactsController { @RequestMapping(value="/contacts/types", method = RequestMethod.GET) @ResponseBody public UserContactType[] getContactTypes() { List<UserContactType> types = service.getAvailableContactTypes(); return types.toArray(new UserContactType[types.size()]); } @Autowired  UserContactsController(UserContactsService service); @RequestMapping(value="/contacts/types", method = RequestMethod.GET) @ResponseBody UserContactType[] getContactTypes();  }### Answer:
@Test public void testGetContactTypes() { List<UserContactType> expectedTypes = new ArrayList<UserContactType>(); UserContactType expectedType = createUserContactType(); expectedTypes.add(expectedType); when(service.getAvailableContactTypes()).thenReturn(expectedTypes); UserContactType[] types = controller.getContactTypes(); assertEquals(types.length, expectedTypes.size()); assertEquals(types[0].getIcon(), expectedType.getIcon()); assertEquals(types[0].getTypeName(), expectedType.getTypeName()); }