-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring: Introduction of CurationDataHandle to enable additional …
…ways to represent/reference curation data (#254)
- Loading branch information
Showing
14 changed files
with
107 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
core/src/main/java/com/devonfw/tools/solicitor/componentinfo/CurationDataHandle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.devonfw.tools.solicitor.componentinfo; | ||
|
||
/** | ||
* A handle which represents/references curation data. | ||
*/ | ||
public interface CurationDataHandle { | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
core/src/main/java/com/devonfw/tools/solicitor/componentinfo/SelectorCurationDataHandle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.devonfw.tools.solicitor.componentinfo; | ||
|
||
/** | ||
* An implementation of a {@link CurationDataHandle} which references curation data via a dataSelector. This | ||
* dataSelector is a string which might e.g. denote a branch in a Git repository. Further information (like e.g. the | ||
* PackageURL) is needed to retrieve the curation data. | ||
*/ | ||
public class SelectorCurationDataHandle implements CurationDataHandle { | ||
|
||
private String curationDataSelector; | ||
|
||
/** | ||
* The constructor. | ||
* | ||
* @param curationDataSelector the curationDataSelector which is references the curation data. <code>null</code> | ||
* indicates that the default should be used. <code>"none"</code> indicates that no curation should be applied. | ||
*/ | ||
public SelectorCurationDataHandle(String curationDataSelector) { | ||
|
||
this.curationDataSelector = curationDataSelector; | ||
|
||
} | ||
|
||
/** | ||
* Gets the curationDataSelctor encapsulated by this handle. | ||
* | ||
* @return the curationDataSelector | ||
*/ | ||
public String getCurationDataSelector() { | ||
|
||
return this.curationDataSelector; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
import com.devonfw.tools.solicitor.common.packageurl.AllKindsPackageURLHandler; | ||
import com.devonfw.tools.solicitor.componentinfo.ComponentInfoAdapterException; | ||
import com.devonfw.tools.solicitor.componentinfo.SelectorCurationDataHandle; | ||
import com.devonfw.tools.solicitor.componentinfo.curation.SingleFileCurationProvider; | ||
import com.devonfw.tools.solicitor.componentinfo.curation.model.ComponentInfoCuration; | ||
|
||
|
@@ -44,9 +45,11 @@ void testFindCurationsWithSelectorNull() throws ComponentInfoAdapterException { | |
|
||
ComponentInfoCuration result; | ||
|
||
result = this.objectUnderTest.findCurations("pkg:maven/somenamespace/[email protected]", null); | ||
result = this.objectUnderTest.findCurations("pkg:maven/somenamespace/[email protected]", | ||
new SelectorCurationDataHandle(null)); | ||
assertEquals("https://scancode-licensedb.aboutcode.org/apache-2.0.LICENSE", result.getLicenses().get(0).getUrl()); | ||
result = this.objectUnderTest.findCurations("pkg:maven/somenamespace/[email protected]", null); | ||
result = this.objectUnderTest.findCurations("pkg:maven/somenamespace/[email protected]", | ||
new SelectorCurationDataHandle(null)); | ||
assertEquals("https://scancode-licensedb.aboutcode.org/bsd-simplified.LICENSE", | ||
result.getLicenses().get(0).getUrl()); | ||
} | ||
|
@@ -62,7 +65,8 @@ void testFindCurationsWithSelectorNone() throws ComponentInfoAdapterException { | |
|
||
ComponentInfoCuration result; | ||
|
||
result = this.objectUnderTest.findCurations("pkg:maven/somenamespace/[email protected]", "none"); | ||
result = this.objectUnderTest.findCurations("pkg:maven/somenamespace/[email protected]", | ||
new SelectorCurationDataHandle("none")); | ||
assertNull(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
import com.devonfw.tools.solicitor.common.packageurl.AllKindsPackageURLHandler; | ||
import com.devonfw.tools.solicitor.componentinfo.ComponentInfo; | ||
import com.devonfw.tools.solicitor.componentinfo.ComponentInfoAdapterException; | ||
import com.devonfw.tools.solicitor.componentinfo.SelectorCurationDataHandle; | ||
import com.devonfw.tools.solicitor.componentinfo.curation.SingleFileCurationProvider; | ||
|
||
/** | ||
|
@@ -57,7 +58,8 @@ public void testGetComponentInfoWithoutCurations() throws ComponentInfoAdapterEx | |
|
||
// when | ||
ComponentInfo scancodeComponentInfo = this.filteredScancodeComponentInfoProvider.getComponentInfo( | ||
"pkg:maven/com.devonfw.tools/[email protected]", "someCurationSelector"); | ||
"pkg:maven/com.devonfw.tools/[email protected]", | ||
new SelectorCurationDataHandle("someCurationSelector")); | ||
|
||
// then | ||
assertNotNull(scancodeComponentInfo.getComponentInfoData()); | ||
|
@@ -83,7 +85,8 @@ public void testGetComponentInfoWithCurationsAndExclusions() throws ComponentInf | |
.setCurationsFileName("src/test/resources/scancodefileadapter/curations_with_exclusions.yaml"); | ||
// when | ||
ComponentInfo scancodeComponentInfo = this.filteredScancodeComponentInfoProvider.getComponentInfo( | ||
"pkg:maven/com.devonfw.tools/[email protected]", "someCurationSelector"); | ||
"pkg:maven/com.devonfw.tools/[email protected]", | ||
new SelectorCurationDataHandle("someCurationSelector")); | ||
|
||
// then | ||
assertNotNull(scancodeComponentInfo.getComponentInfoData()); | ||
|
@@ -110,7 +113,8 @@ public void testGetComponentInfoWithCurationsAndWithoutExclusions() throws Compo | |
|
||
// when | ||
ComponentInfo scancodeComponentInfo = this.filteredScancodeComponentInfoProvider.getComponentInfo( | ||
"pkg:maven/com.devonfw.tools/[email protected]", "someCurationSelector"); | ||
"pkg:maven/com.devonfw.tools/[email protected]", | ||
new SelectorCurationDataHandle("someCurationSelector")); | ||
|
||
// then | ||
assertNotNull(scancodeComponentInfo.getComponentInfoData()); | ||
|
Oops, something went wrong.