### Question:
GenerateUtil { public static void generateContract(MavenProject project, String contractOutput, String contractFileType, String type) { Map<String, Object> contractConfig = new HashMap<>(); try { contractConfig.put("classpathUrls", project.getRuntimeClasspathElements()); } catch (DependencyResolutionRequiredException e) { throw new RuntimeException("Failed to get runtime class elements", e); } contractConfig.put("outputDir", contractOutput); contractConfig.put("contractFileType", contractFileType); ContractsGenerator contractGenerator = GeneratorFactory.getGenerator(ContractsGenerator.class, type); Objects.requireNonNull(contractGenerator).configure(contractConfig); contractGenerator.generate(); }  static void generateContract(MavenProject project, String contractOutput, String contractFileType,
      String type);  }### Answer:
@SuppressWarnings("unchecked") @Test public void testGenerateContract() throws DependencyResolutionRequiredException { MavenProject project = mock(MavenProject.class); String contractOutput = "target/GenerateUtilTest/contract"; when(project.getRuntimeClasspathElements()).thenThrow(DependencyResolutionRequiredException.class); try { generateContract(project, contractOutput, "yaml", "default"); fail("Run 'testGenerateContract' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Failed to get runtime class elements", e.getMessage()); } }