### Question:
OrganizationResolversImpl implements OrganizationResolvers { @Override public DataFetcher<CompletableFuture<Organization>> getOrganizationDataFetcher() { return environment -> { long organizationId = getOrganizationId(environment); if (organizationId <= 0) { return null; } DataLoader<Long, Organization> dataLoader = environment.getDataLoader(OrganizationBatchLoader.KEY); return dataLoader.load(organizationId); }; }  @Reference(unbind = "-") void setOrganizationLocalService(OrganizationLocalService organizationLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<Organization>> getOrganizationsDataFetcher(); @Override DataFetcher<CompletableFuture<Organization>> getOrganizationDataFetcher(); @Override DataFetcher<Organization> getOrganizationByNameDataFetcher(); @Override DataFetcher<Organization> createOrganizationDataFetcher(); @Override DataFetcher<Organization> updateOrganizationDataFetcher(); @Override DataFetcher<Organization> deleteOrganizationDataFetcher();  }### Answer:
@Test public void getOrganizationDataFetcher_should_return_the_searched_object() throws Exception { Organization expectedResult = mock(Organization.class); expectedResult.setOrganizationId(ORGANIZATION_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("organizationId")) .thenReturn(ORGANIZATION_ID); when(dataLoader.load(ORGANIZATION_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<Organization> asyncResult = resolvers.getOrganizationDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); Organization result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getOrganizationDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("organizationId")) .thenReturn(0L); CompletableFuture<Organization> asyncResult = resolvers.getOrganizationDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getOrganizationDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("organizationId")) .thenReturn(ORGANIZATION_ID); when(dataLoader.load(ORGANIZATION_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<Organization> asyncResult = resolvers.getOrganizationDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); Organization result = asyncResult.get(); assertNull(result); }