### Question:
ListTypeResolversImpl implements ListTypeResolvers { @Override public DataFetcher<ListType> createListTypeDataFetcher() { return environment -> { String name = util.getStringArg(environment, "name"); String type = util.getStringArg(environment, "type"); return listtypeLocalService.addListType(name, type); }; }  @Reference(unbind = "-") void setListTypeLocalService(ListTypeLocalService listtypeLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<ListType>> getListTypesDataFetcher(); @Override DataFetcher<List<ListType>> getListTypesByTypeDataFetcher(); @Override DataFetcher<CompletableFuture<ListType>> getListTypeDataFetcher(); @Override DataFetcher<ListType> createListTypeDataFetcher(); @Override DataFetcher<ListType> deleteListTypeDataFetcher();  }### Answer:
@Test public void createListTypeDataFetcher_should_return_new_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("name", NAME); arguments.put("type", TYPE); DataFetchingEnvironment environment = getTestEnvironment(arguments); ListType expectedResult = mock(ListType.class); expectedResult.setName(NAME); expectedResult.setType(TYPE); useMockGraphQLUtil(environment, true); when(localService.addListType(eq(NAME), eq(TYPE))) .thenReturn(expectedResult); ListType result = resolvers.createListTypeDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = PortalException.class) public void createListTypeDataFetcher_without_args_should_throw_validation_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); useMockGraphQLUtil(environment, false); when(localService.addListType(anyString(), anyString())) .thenThrow(PortalException.class); ListType result = resolvers.createListTypeDataFetcher() .get(environment); assertNull(result); }