Skip to content

Commit

Permalink
WINDUPRULE-985 Rules testing: technology-statistics-exists has incons…
Browse files Browse the repository at this point in the history
…istent number-found (#1663)

* WINDUPRULE-978 Fixed embedded JARs technology usage identification

* WINDUPRULE-985 Set TechnologyUsageStatisticsModel for the root project

* WINDUPRULE-978 technology-statistics-exists: manage technologies with  both 'Java EE' and 'Embedded' tags

* WINDUPRULE-985 Tech tag is now attached to project
  • Loading branch information
mrizzi committed May 10, 2023
1 parent bab719c commit 1303d32
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Expand Up @@ -49,7 +49,10 @@ private boolean matchesExpectations(TechnologyUsageStatisticsModel model) {
if (this.expectedCount != model.getOccurrenceCount())
return false;

return model.getTags().containsAll(this.expectedTags);
// expectedTags could contain both "Java EE" and "Embedded"
// while the model could just have one of them
// so that's why is expectedTags that can contain model's tags
return this.expectedTags.containsAll(model.getTags());
}

public String getTechnologyName() {
Expand Down
Expand Up @@ -28,7 +28,7 @@ public TechnologyUsageStatisticsModel getOrCreate(ProjectModel projectModel, Str
TechnologyUsageStatisticsModel result = null;

for (TechnologyUsageStatisticsModel candidate : byName) {
if (candidate.getProjectModel().equals(projectModel)) {
if (candidate.getProjectModel().equals(projectModel.getRootProjectModel())) {
result = candidate;
break;
}
Expand All @@ -37,7 +37,10 @@ public TechnologyUsageStatisticsModel getOrCreate(ProjectModel projectModel, Str
if (result == null) {
result = create();
result.setComputed(new Date());
result.setProjectModel(projectModel);
// in case of JAR files embedded in the analyzed application,
// projectModel is the JAR itself so a technology won't be
// properly assigned to the analyzed application (i.e. getRootProjectModel())
result.setProjectModel(projectModel.getRootProjectModel());
result.setName(technologyName);
result.setOccurrenceCount(0);
}
Expand Down
Expand Up @@ -148,7 +148,7 @@ public void testDuplicateArchiveHandling() throws Exception {
for (TechnologyUsageStatisticsModel model : service.findAllByProperty(TechnologyUsageStatisticsModel.NAME, SHARED_LIBS_TECH)) {
LOG.info("Technology Usage Statistics Model: " + model);
ProjectModel project = model.getProjectModel();
if (project.getRootFileModel() != null && project.getRootFileModel().getFileName().equals("migration-support-1.0.0.jar"))
if (project.getRootFileModel() != null && project.getRootFileModel().getFileName().equals("shared-libs"))
foundMigrationSupportModule = true;
LOG.info("Project: " + project.getRootFileModel().getFileName());
numberFound++;
Expand Down

0 comments on commit 1303d32

Please sign in to comment.