### Question:
MBThreadResolversImpl implements MBThreadResolvers { @Override public DataFetcher<MBThread> createMBThreadDataFetcher() { return environment -> { long categoryId = util.getLongArg(environment, "categoryId"); MBMessage message = util.getMBMessageArg(environment, "message"); ServiceContext serviceContext = new ServiceContext(); return mbThreadLocalService.addThread( categoryId, message, serviceContext); }; }  @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 createMBThreadDataFetcher_should_return_new_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("categoryId", CATEGORY_ID); arguments.put("message", MESSAGE); DataFetchingEnvironment environment = getTestEnvironment(arguments); MBThread expectedResult = mock(MBThread.class); expectedResult.setThreadId(THREAD_ID); expectedResult.setCategoryId(CATEGORY_ID); expectedResult.setRootMessageId(MESSAGE.getMessageId()); useMockGraphQLUtil(environment, true); when(localService.addThread(eq(CATEGORY_ID), eq(MESSAGE), any(ServiceContext.class))) .thenReturn(expectedResult); MBThread result = resolvers.createMBThreadDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = PortalException.class) public void createMBThreadDataFetcher_without_args_should_throw_validation_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); useMockGraphQLUtil(environment, false); when(localService.addThread(anyLong(), any(), any(ServiceContext.class))) .thenThrow(PortalException.class); MBThread result = resolvers.createMBThreadDataFetcher() .get(environment); assertNull(result); }