### Question:
AssetLinkResolversImpl implements AssetLinkResolvers { @Override public DataFetcher<AssetLink> deleteAssetLinkDataFetcher() { return environment -> { long linkId = util.getLongArg(environment, "linkId"); return assetLinkLocalService.deleteAssetLink(linkId); }; }  @Reference(unbind = "-") void setAssetLinkLocalService(AssetLinkLocalService assetLinkLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<AssetLink>> getAssetLinksDataFetcher(); @Override DataFetcher<CompletableFuture<AssetLink>> getAssetLinkDataFetcher(); @Override DataFetcher<AssetLink> createAssetLinkDataFetcher(); @Override DataFetcher<AssetLink> updateAssetLinkDataFetcher(); @Override DataFetcher<AssetLink> deleteAssetLinkDataFetcher();  }### Answer:
@Test public void deleteAssetLinkDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("linkId", LINK_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); AssetLink expectedResult = mock(AssetLink.class); expectedResult.setLinkId(LINK_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteAssetLink(eq(LINK_ID))) .thenReturn(expectedResult); AssetLink result = resolvers.deleteAssetLinkDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchLinkException.class) public void deleteAssetLinkDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); AssetLink expectedResult = mock(AssetLink.class); expectedResult.setLinkId(LINK_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteAssetLink(eq(LINK_ID))) .thenThrow(NoSuchLinkException.class); AssetLink result = resolvers.deleteAssetLinkDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchLinkException.class) public void deleteAssetLinkDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("linkId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); AssetLink expectedResult = mock(AssetLink.class); expectedResult.setLinkId(LINK_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("linkId"))) .thenReturn(789456L); when(localService.deleteAssetLink(eq(789456L))) .thenThrow(NoSuchLinkException.class); AssetLink result = resolvers.deleteAssetLinkDataFetcher() .get(environment); assertNull(result); }