### Question:
GroupResolversImpl implements GroupResolvers { @Override public DataFetcher<Group> deleteGroupDataFetcher() { return environment -> { long groupId = util.getLongArg(environment, "groupId"); return groupLocalService.deleteGroup(groupId); }; }  @Reference(unbind = "-") void setGroupLocalService(GroupLocalService groupLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<Group>> getGroupsDataFetcher(); @Override DataFetcher<CompletableFuture<Group>> getGroupDataFetcher(); @Override DataFetcher<Group> getGroupByKeyDataFetcher(); @Override DataFetcher<Group> createGroupDataFetcher(); @Override DataFetcher<Group> updateGroupDataFetcher(); @Override DataFetcher<Group> deleteGroupDataFetcher();  }### Answer:
@Test public void deleteGroupDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("groupId", GROUP_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); Group expectedResult = mock(Group.class); expectedResult.setGroupId(GROUP_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteGroup(eq(GROUP_ID))) .thenReturn(expectedResult); Group result = resolvers.deleteGroupDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchGroupException.class) public void deleteGroupDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); Group expectedResult = mock(Group.class); expectedResult.setGroupId(GROUP_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteGroup(eq(GROUP_ID))) .thenThrow(NoSuchGroupException.class); Group result = resolvers.deleteGroupDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchGroupException.class) public void deleteGroupDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("groupId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); Group expectedResult = mock(Group.class); expectedResult.setGroupId(GROUP_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("groupId"))) .thenReturn(789456L); when(localService.deleteGroup(eq(789456L))) .thenThrow(NoSuchGroupException.class); Group result = resolvers.deleteGroupDataFetcher() .get(environment); assertNull(result); }