### Question:
MBThreadResolversImpl implements MBThreadResolvers { @Override public DataFetcher<MBThread> deleteMBThreadDataFetcher() { return environment -> { long threadId = util.getLongArg(environment, "threadId"); return mbThreadLocalService.deleteMBThread(threadId); }; }  @Reference(unbind = "-") void setMBThreadLocalService(MBThreadLocalService mbThreadLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<MBThread>> getMBThreadsDataFetcher(); @Override DataFetcher<CompletableFuture<MBThread>> getMBThreadDataFetcher(); @Override DataFetcher<MBThread> createMBThreadDataFetcher(); @Override DataFetcher<MBThread> deleteMBThreadDataFetcher();  }### Answer:
@Test public void deleteMBThreadDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("threadId", THREAD_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); MBThread expectedResult = mock(MBThread.class); expectedResult.setThreadId(THREAD_ID); useMockGraphQLUtil(environment, true); when(localService.deleteMBThread(eq(THREAD_ID))) .thenReturn(expectedResult); MBThread result = resolvers.deleteMBThreadDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchThreadException.class) public void deleteMBThreadDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); MBThread expectedResult = mock(MBThread.class); expectedResult.setThreadId(THREAD_ID); useMockGraphQLUtil(environment, true); when(localService.deleteMBThread(eq(THREAD_ID))) .thenThrow(NoSuchThreadException.class); MBThread result = resolvers.deleteMBThreadDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchThreadException.class) public void deleteMBThreadDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("threadId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); MBThread expectedResult = mock(MBThread.class); expectedResult.setThreadId(THREAD_ID); useMockGraphQLUtil(environment, false); when(graphQLUtil.getLongArg(eq(environment), eq("threadId"))) .thenReturn(789456L); when(localService.deleteMBThread(eq(789456L))) .thenThrow(NoSuchThreadException.class); MBThread result = resolvers.deleteMBThreadDataFetcher() .get(environment); assertNull(result); }