### Question:
DDMStructureResolversImpl implements DDMStructureResolvers { @Override public DataFetcher<DDMStructure> deleteDDMStructureDataFetcher() { return environment -> { long structureId = util.getLongArg(environment, "structureId"); return ddmStructureLocalService.deleteDDMStructure(structureId); }; }  @Reference(unbind = "-") void setDDMStructureLocalService(DDMStructureLocalService ddmstructureLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<DDMStructure>> getDDMStructuresDataFetcher(); @Override DataFetcher<CompletableFuture<DDMStructure>> getDDMStructureDataFetcher(); @Override DataFetcher<DDMStructure> getDDMStructureByKeyDataFetcher(); @Override DataFetcher<DDMStructure> createDDMStructureDataFetcher(); @Override DataFetcher<DDMStructure> createDDMStructureForJournalArticleDataFetcher(); @Override DataFetcher<DDMStructure> updateDDMStructureDataFetcher(); @Override DataFetcher<DDMStructure> updateDDMStructureForJournalArticleDataFetcher(); @Override DataFetcher<DDMStructure> deleteDDMStructureDataFetcher();  }### Answer:
@Test public void deleteDDMStructureDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("structureId", STRUCTURE_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); DDMStructure expectedResult = mock(DDMStructure.class); expectedResult.setStructureId(STRUCTURE_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteDDMStructure(eq(STRUCTURE_ID))) .thenReturn(expectedResult); DDMStructure result = resolvers.deleteDDMStructureDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchStructureException.class) public void deleteDDMStructureDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); DDMStructure expectedResult = mock(DDMStructure.class); expectedResult.setStructureId(STRUCTURE_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteDDMStructure(eq(STRUCTURE_ID))) .thenThrow(NoSuchStructureException.class); DDMStructure result = resolvers.deleteDDMStructureDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchStructureException.class) public void deleteDDMStructureDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("structureId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); DDMStructure expectedResult = mock(DDMStructure.class); expectedResult.setStructureId(STRUCTURE_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("structureId"))) .thenReturn(789456L); when(localService.deleteDDMStructure(eq(789456L))) .thenThrow(NoSuchStructureException.class); DDMStructure result = resolvers.deleteDDMStructureDataFetcher() .get(environment); assertNull(result); }