### Question:
ExpandoValueResolversImpl implements ExpandoValueResolvers { @Override public DataFetcher<ExpandoValue> deleteExpandoValueDataFetcher() { return environment -> { long valueId = util.getLongArg(environment, "valueId"); return expandoValueLocalService.deleteExpandoValue(valueId); }; }  @Reference(unbind = "-") void setExpandoValueLocalService(ExpandoValueLocalService expandoValueLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<ExpandoValue>> getExpandoValuesDataFetcher(); @Override DataFetcher<CompletableFuture<ExpandoValue>> getExpandoValueDataFetcher(); @Override DataFetcher<ExpandoValue> createExpandoValueForStringDataFetcher(); @Override DataFetcher<ExpandoValue> createExpandoValueForIntDataFetcher(); @Override DataFetcher<ExpandoValue> createExpandoValueForLongDataFetcher(); @Override DataFetcher<ExpandoValue> createExpandoValueForDoubleDataFetcher(); @Override DataFetcher<ExpandoValue> createExpandoValueForBooleanDataFetcher(); @Override DataFetcher<ExpandoValue> deleteExpandoValueDataFetcher();  }### Answer:
@Test public void deleteExpandoValueDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("valueId", VALUE_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); ExpandoValue expectedResult = mock(ExpandoValue.class); expectedResult.setValueId(VALUE_ID); useMockGraphQLUtil(environment, true); when(localService.deleteExpandoValue(eq(VALUE_ID))) .thenReturn(expectedResult); ExpandoValue result = resolvers.deleteExpandoValueDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchValueException.class) public void deleteExpandoValueDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); ExpandoValue expectedResult = mock(ExpandoValue.class); expectedResult.setValueId(VALUE_ID); useMockGraphQLUtil(environment, true); when(localService.deleteExpandoValue(eq(VALUE_ID))) .thenThrow(NoSuchValueException.class); ExpandoValue result = resolvers.deleteExpandoValueDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchValueException.class) public void deleteExpandoValueDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("valueId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); ExpandoValue expectedResult = mock(ExpandoValue.class); expectedResult.setValueId(VALUE_ID); useMockGraphQLUtil(environment, false); when(graphQLUtil.getLongArg(eq(environment), eq("valueId"))) .thenReturn(789456L); when(localService.deleteExpandoValue(eq(789456L))) .thenThrow(NoSuchValueException.class); ExpandoValue result = resolvers.deleteExpandoValueDataFetcher() .get(environment); assertNull(result); }