Пример #1
0
  @Override
  public void setUp() {

    ServiceProvider provider = ServiceProvider.getInstance();
    IDefineService defService = provider.getDefineService();

    String path = TestProjectFinder.lookupProject("java", "recognition");
    ArrayList<String> paths = new ArrayList<String>();
    paths.add(path);
    ArrayList<ProjectDTO> projects = new ArrayList<ProjectDTO>();
    projects.add(
        new ProjectDTO(
            "TestProject",
            new ArrayList<String>(),
            "java",
            "1.0",
            "test project for unit tests",
            new ArrayList<AnalysedModuleDTO>()));
    defService.createApplication("Java Recognition", projects, "1.0");

    service = provider.getAnalyseService();

    try {
      if (!isAnalysed) {
        service.analyseApplication(projects.get(0));
        isAnalysed = true;
      }

    } catch (Exception e) {
      System.out.println(
          "We're sorry. You need to have a java project 'benchmark_application' with inside the benchmark_application. Or you have the wrong version of the benchmark_application.");
      System.exit(0);
    }
  }
 private int getNumberofDependenciesBetweenModulesInIntendedArchitecture(
     String fromModule, String toModule) {
   analyseService = ServiceProvider.getInstance().getAnalyseService();
   IDefineService defineService = ServiceProvider.getInstance().getDefineService();
   HashSet<String> physicalFromClassPaths =
       defineService.getModule_AllPhysicalClassPathsOfModule(fromModule);
   HashSet<String> physicalToClassPaths =
       defineService.getModule_AllPhysicalClassPathsOfModule(toModule);
   ArrayList<DependencyDTO> allFoundDependencies = new ArrayList<DependencyDTO>();
   for (String fromPackages : physicalFromClassPaths) {
     for (String toPackages : physicalToClassPaths) {
       for (DependencyDTO dependency :
           analyseService.getDependenciesFromSoftwareUnitToSoftwareUnit(
               fromPackages, toPackages)) {
         allFoundDependencies.add(dependency);
       }
     }
   }
   int numberOfDependencies = allFoundDependencies.size();
   return numberOfDependencies;
 }
 boolean isEnabled(String ruleTypeKey, String violationTypeKey) {
   final String currentLanguage = defineService.getApplicationDetails().programmingLanguage;
   return isEnabled(currentLanguage, ruleTypeKey, violationTypeKey);
 }