### Question:
ListTypeResolversImpl implements ListTypeResolvers { @Override public DataFetcher<ListType> deleteListTypeDataFetcher() { return environment -> { long listTypeId = util.getLongArg(environment, "listTypeId"); return listtypeLocalService.deleteListType(listTypeId); }; }  @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 deleteListTypeDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("listTypeId", LIST_TYPE_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); ListType expectedResult = mock(ListType.class); expectedResult.setListTypeId(LIST_TYPE_ID); useMockGraphQLUtil(environment, true); when(localService.deleteListType(eq(LIST_TYPE_ID))) .thenReturn(expectedResult); ListType result = resolvers.deleteListTypeDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchListTypeException.class) public void deleteListTypeDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); ListType expectedResult = mock(ListType.class); expectedResult.setListTypeId(LIST_TYPE_ID); useMockGraphQLUtil(environment, true); when(localService.deleteListType(eq(LIST_TYPE_ID))) .thenThrow(NoSuchListTypeException.class); ListType result = resolvers.deleteListTypeDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchListTypeException.class) public void deleteListTypeDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("listTypeId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); ListType expectedResult = mock(ListType.class); expectedResult.setListTypeId(LIST_TYPE_ID); useMockGraphQLUtil(environment, false); when(graphQLUtil.getLongArg(eq(environment), eq("listTypeId"))) .thenReturn(789456L); when(localService.deleteListType(eq(789456L))) .thenThrow(NoSuchListTypeException.class); ListType result = resolvers.deleteListTypeDataFetcher() .get(environment); assertNull(result); }