### Question:
ExpandoTableResolversImpl implements ExpandoTableResolvers { @Override public DataFetcher<ExpandoTable> deleteExpandoTableDataFetcher() { return environment -> { long tableId = util.getLongArg(environment, "tableId"); return expandoTableLocalService.deleteExpandoTable(tableId); }; }  @Reference(unbind = "-") void setExpandoTableLocalService(ExpandoTableLocalService expandoTableLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<ExpandoTable>> getExpandoTablesDataFetcher(); @Override DataFetcher<CompletableFuture<ExpandoTable>> getExpandoTableDataFetcher(); @Override DataFetcher<ExpandoTable> createExpandoTableDataFetcher(); @Override DataFetcher<ExpandoTable> updateExpandoTableDataFetcher(); @Override DataFetcher<ExpandoTable> deleteExpandoTableDataFetcher();  }### Answer:
@Test public void deleteExpandoTableDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("tableId", TABLE_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); ExpandoTable expectedResult = mock(ExpandoTable.class); expectedResult.setTableId(TABLE_ID); useMockGraphQLUtil(environment, true); when(localService.deleteExpandoTable(eq(TABLE_ID))) .thenReturn(expectedResult); ExpandoTable result = resolvers.deleteExpandoTableDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchTableException.class) public void deleteExpandoTableDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); ExpandoTable expectedResult = mock(ExpandoTable.class); expectedResult.setTableId(TABLE_ID); useMockGraphQLUtil(environment, true); when(localService.deleteExpandoTable(eq(TABLE_ID))) .thenThrow(NoSuchTableException.class); ExpandoTable result = resolvers.deleteExpandoTableDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchTableException.class) public void deleteExpandoTableDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("tableId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); ExpandoTable expectedResult = mock(ExpandoTable.class); expectedResult.setTableId(TABLE_ID); useMockGraphQLUtil(environment, false); when(graphQLUtil.getLongArg(eq(environment), eq("tableId"))) .thenReturn(789456L); when(localService.deleteExpandoTable(eq(789456L))) .thenThrow(NoSuchTableException.class); ExpandoTable result = resolvers.deleteExpandoTableDataFetcher() .get(environment); assertNull(result); }