### Question:
ExpandoRowResolversImpl implements ExpandoRowResolvers { @Override public DataFetcher<ExpandoRow> deleteExpandoRowDataFetcher() { return environment -> { long rowId = util.getLongArg(environment, "rowId"); return expandoRowLocalService.deleteExpandoRow(rowId); }; }  @Reference(unbind = "-") void setExpandoRowLocalService(ExpandoRowLocalService expandoRowLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<ExpandoRow>> getExpandoRowsDataFetcher(); @Override DataFetcher<CompletableFuture<ExpandoRow>> getExpandoRowDataFetcher(); @Override DataFetcher<ExpandoRow> createExpandoRowDataFetcher(); @Override DataFetcher<ExpandoRow> deleteExpandoRowDataFetcher();  }### Answer:
@Test public void deleteExpandoRowDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("rowId", ROW_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); ExpandoRow expectedResult = mock(ExpandoRow.class); expectedResult.setRowId(ROW_ID); useMockGraphQLUtil(environment, true); when(localService.deleteExpandoRow(eq(ROW_ID))) .thenReturn(expectedResult); ExpandoRow result = resolvers.deleteExpandoRowDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchRowException.class) public void deleteExpandoRowDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); ExpandoRow expectedResult = mock(ExpandoRow.class); expectedResult.setRowId(ROW_ID); useMockGraphQLUtil(environment, true); when(localService.deleteExpandoRow(eq(ROW_ID))) .thenThrow(NoSuchRowException.class); ExpandoRow result = resolvers.deleteExpandoRowDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchRowException.class) public void deleteExpandoRowDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("rowId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); ExpandoRow expectedResult = mock(ExpandoRow.class); expectedResult.setRowId(ROW_ID); useMockGraphQLUtil(environment, false); when(graphQLUtil.getLongArg(eq(environment), eq("rowId"))) .thenReturn(789456L); when(localService.deleteExpandoRow(eq(789456L))) .thenThrow(NoSuchRowException.class); ExpandoRow result = resolvers.deleteExpandoRowDataFetcher() .get(environment); assertNull(result); }