diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 9fa6015..3c3d75b 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -1,6 +1,6 @@ # This workflow will build a Java project with Maven # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven - +--- name: Build on: @@ -8,99 +8,178 @@ on: - cron: '0 0 1 * *' workflow_dispatch: push: - # branches: [ main ] + # branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: + versioning: + runs-on: ubuntu-latest + outputs: + semVer: ${{ steps.gitversion.outputs.semVer }} + + steps: + - name: Checkout project + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v4.3.3 + with: + versionSpec: '6.6.x' + + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v4.3.3 + build: + needs: [versioning] + runs-on: ubuntu-latest + + steps: + - name: Checkout project + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 21 + uses: actions/setup-java@v5 + with: + java-version: '21' + distribution: 'adopt' + + - name: Build with Maven + run: | + mvn versions:set "-DnewVersion=${{ needs.versioning.outputs.semVer }}" + mvn -B package -e --file pom.xml + + - name: Check status + run: | + set + echo -n "Current directory: " + pwd + find + + - uses: actions/upload-artifact@v7 + with: + name: OoliteAddonScanner + path: target/OoliteAddonScanner-${{ needs.versioning.outputs.semVer }}-executable.* + test: + needs: [build] runs-on: ubuntu-latest + steps: + - name: Install required packages + run: | + sudo apt-get install -y graphviz + + - name: Set up JDK 21 + uses: actions/setup-java@v5 + with: + java-version: '21' + distribution: 'adopt' + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: OoliteAddonScanner + path: artifacts + + - name: extract distribution + run: | + unzip artifacts/OoliteAddonScanner*.zip + + - name: check filesystem + run: | + find + + - name: Restore expansions cache + id: cache-restore + uses: actions/cache/restore@v3 + with: + path: | + expansion-cache + key: ${{ runner.os }}-expansion_cache + + - name: Run example scan + run: | + B=$(basename "OoliteAddonScanner*") + java -jar $B/$B.jar --out target/OoliteExpansionIndex --cache expansion-cache --maxExpansion 20 + + - uses: actions/upload-artifact@v7 + with: + name: ExampleCatalog + path: target/OoliteExpansionIndex + - name: Save Expansions Cache + id: cache-save + uses: actions/cache/save@v3 + with: + path: | + expansion-cache + key: ${{ runner.os }}-expansion_cache + + release: + needs: [versioning, build, test] + runs-on: ubuntu-latest steps: - - name: Checkout project - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v4.3.3 - with: - versionSpec: '6.6.x' - - - name: Set up JDK 21 - uses: actions/setup-java@v5 - with: - java-version: '21' - distribution: 'adopt' - - - name: Determine Version - id: gitversion - uses: gittools/actions/gitversion/execute@v4.3.3 - - - name: Build with Maven - run: | - mvn versions:set "-DnewVersion=${{ env.GitVersion_SemVer }}" - mvn -B package -e --file pom.xml - - - name: Check status - run: | - set - echo -n "Current directory: " - pwd - find - - - uses: actions/upload-artifact@v7 - with: - name: OoliteAddonScanner - path: target/OoliteAddonScanner-${{ env.GitVersion_SemVer }}-executable.zip - - - name: Remove old prereleases - if: github.ref != 'refs/heads/main' - uses: s00d/delete-older-releases@0.2.1 - with: - #repo: / # defaults to current repo - keep_latest: 3 - delete_tag_pattern: v - delete_type: 'prerelease' - delete_branch: '${{ github.ref_name }}' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create Prerelease - if: github.ref != 'refs/heads/main' - id: create_prerelease - uses: "marvinpinto/action-automatic-releases@latest" - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "v${{ env.GitVersion_SemVer }}" - prerelease: true - title: "OoliteAddonScanner v${{ env.GitVersion_SemVer }}" - files: | - target/*.zip - target/*.tar.gz - - - name: Remove old releases - if: github.ref == 'refs/heads/main' - uses: s00d/delete-older-releases@0.2.1 - with: - #repo: / # defaults to current repo - keep_latest: 3 - delete_tag_pattern: v - delete_type: 'release' - delete_branch: 'main' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create Release - if: github.ref == 'refs/heads/main' - id: create_release - uses: "marvinpinto/action-automatic-releases@latest" - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "v${{ env.GitVersion_SemVer }}" - prerelease: false - title: "OoliteAddonScanner v${{ env.GitVersion_SemVer }}" - files: | - target/*.zip - target/*.tar.gz + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: OoliteAddonScanner + path: artifacts + + - name: check filesystem + run: | + find + + - name: Remove old prereleases + if: github.ref != 'refs/heads/main' + uses: s00d/delete-older-releases@0.2.1 + with: + # repo: / # defaults to current repo + keep_latest: 3 + delete_tag_pattern: v + delete_type: 'prerelease' + delete_branch: '${{ github.ref_name }}' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Prerelease + if: github.ref != 'refs/heads/main' + id: create_prerelease + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "v${{ needs.versioning.outputs.semVer }}" + prerelease: true + title: "OoliteAddonScanner v${{ needs.versioning.outputs.semVer }}" + files: | + artifacts/*.zip + artifacts/*.tar.gz + + - name: Remove old releases + if: github.ref == 'refs/heads/main' + uses: s00d/delete-older-releases@0.2.1 + with: + # repo: / # defaults to current repo + keep_latest: 3 + delete_tag_pattern: v + delete_type: 'release' + delete_branch: 'main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Release + if: github.ref == 'refs/heads/main' + id: create_release + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "v${{ needs.versioning.outputs.semVer }}" + prerelease: false + title: "OoliteAddonScanner v${{ needs.versioning.outputs.semVer }}" + files: | + target/*.zip + target/*.tar.gz diff --git a/nbactions-Indexer.xml b/nbactions-Indexer.xml index 42e868a..ea76245 100644 --- a/nbactions-Indexer.xml +++ b/nbactions-Indexer.xml @@ -12,7 +12,7 @@ ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - --out target/output --maxExpansion 290 + --out target/output --maxExpansion 2900 com.chaudhuri.ooliteaddonscanner2.Main java @@ -29,7 +29,7 @@ -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - --out target/output --maxExpansion 290 + --out target/output --maxExpansion 2900 com.chaudhuri.ooliteaddonscanner2.Main java true @@ -49,7 +49,7 @@ ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} com.chaudhuri.ooliteaddonscanner2.Main java - --out target/output --maxExpansion 290 + --out target/output --maxExpansion 2900 diff --git a/src/main/java/com/chaudhuri/ooliteaddonscanner2/AddonsUtil.java b/src/main/java/com/chaudhuri/ooliteaddonscanner2/AddonsUtil.java index 9a3e0ea..819ddf2 100644 --- a/src/main/java/com/chaudhuri/ooliteaddonscanner2/AddonsUtil.java +++ b/src/main/java/com/chaudhuri/ooliteaddonscanner2/AddonsUtil.java @@ -313,6 +313,7 @@ public static void readOolite(ExpansionCache cache, Registry registry) throws IO String url = null; Map manifest = null; + // find out the latest Download URL from Github try { manifest = cache.getOoliteManifest(tag); } catch (Exception e) { @@ -323,6 +324,8 @@ public static void readOolite(ExpansionCache cache, Registry registry) throws IO } catch (Exception e) { throw new IllegalStateException("Could not get download url for Oolite from manifest", e); } + + // now download Oolite from that URL try (InputStream olitezip = cache.getPluginInputStream(url); ZipInputStream zin = new ZipInputStream(olitezip)) { Expansion oxp = new Expansion(); oxp.setDownloadUrl(url); diff --git a/src/main/java/com/chaudhuri/ooliteaddonscanner2/Registry.java b/src/main/java/com/chaudhuri/ooliteaddonscanner2/Registry.java index 4ece4db..18757e1 100644 --- a/src/main/java/com/chaudhuri/ooliteaddonscanner2/Registry.java +++ b/src/main/java/com/chaudhuri/ooliteaddonscanner2/Registry.java @@ -45,8 +45,8 @@ public class Registry { public static final String EXPANSION_REQUIRED_OOLITE_VERSION = "required_oolite_version"; private final Map expansions; - private final Map equipment; - private final Map ships; + private final Map> equipment; + private final Map> ships; private final List warnings; private final Properties properties; @@ -411,19 +411,17 @@ public void addShip(Ship ship) { throw new IllegalArgumentException("Ship must have expansion reference"); } - if (ships.containsKey(ship.getIdentifier())) { - addWarning(String.format("Replacing %s/%s with %s/%s", - ships.get(ship.getIdentifier()).getExpansion().getName(), - ships.get(ship.getIdentifier()).getName(), - ship.getExpansion().getName(), - ship.getName())); + List list = ships.get(ship.getIdentifier()); + if (list == null) { + list = new ArrayList<>(); + ships.put(ship.getIdentifier(), list); } - - ships.put(ship.getIdentifier(), ship); + list.add(ship); } /** - * Adds equipment. + * Adds equipment to the registry. If existing equipment gets replaced + * a warning is logged. * * @param equipment the equipment */ @@ -434,14 +432,13 @@ public void addEquipment(Equipment equipment) { if (equipment.getExpansion() == null) { throw new IllegalArgumentException("equipment must have expansion"); } - if (this.equipment.containsKey(equipment.getIdentifier())) { - addWarning(String.format("Replacing %s/%s with %s/%s", - this.equipment.get(equipment.getIdentifier()).getExpansion().getName(), - this.equipment.get(equipment.getIdentifier()).getName(), - equipment.getExpansion().getName(), - equipment.getName())); + + List list = this.equipment.get(equipment.getIdentifier()); + if (list == null) { + list = new ArrayList<>(); + this.equipment.put(equipment.getIdentifier(), list); } - this.equipment.put(equipment.getIdentifier(), equipment); + list.add(equipment); } /** @@ -486,7 +483,13 @@ public void addEquipment(Expansion expansion, PlistParser.ListContext lc) throws } expansion.addEquipment(eq); - this.equipment.put(eq.getIdentifier(), eq); + + List list = equipment.get(eq.getIdentifier()); + if (list == null) { + list = new ArrayList<>(); + equipment.put(eq.getIdentifier(), list); + } + list.add(eq); } /** @@ -656,7 +659,12 @@ public List getExpansionsByUploadDate() { * @return the list */ public List getEquipment() { - return new ArrayList<>(equipment.values()); + //return new ArrayList<>(equipment.values()); + List all = new ArrayList<>(); + for (List list: equipment.values()) { + all.addAll(list); + } + return all; } /** @@ -665,7 +673,7 @@ public List getEquipment() { * @return the list */ public List getEquipmentByName() { - ArrayList result = new ArrayList<>(equipment.values()); + ArrayList result = new ArrayList<>(getEquipment()); Collections.sort(result, (t, t1) -> t.getName().compareTo(t1.getName())); return result; } @@ -676,7 +684,11 @@ public List getEquipmentByName() { * @return the list */ public List getShips() { - return new ArrayList<>(ships.values()); + List all = new ArrayList<>(); + for (List list: ships.values()) { + all.addAll(list); + } + return all; } /** @@ -685,7 +697,7 @@ public List getShips() { * @return the list */ public List getShipsByName() { - ArrayList result = new ArrayList<>(ships.values()); + ArrayList result = new ArrayList<>(getShips()); Collections.sort(result, (t, t1) -> t.getName().compareTo(t1.getName())); return result; } @@ -698,8 +710,8 @@ public List getShipsByName() { public List getAllByIdentifier() { ArrayList result = new ArrayList<>(); result.addAll(expansions.values()); - result.addAll(equipment.values()); - result.addAll(ships.values()); + result.addAll(getEquipment()); + result.addAll(getShips()); Collections.sort(result, (t, t1) -> t.getIdentifier().compareTo(t1.getIdentifier())); diff --git a/src/main/java/com/chaudhuri/ooliteaddonscanner2/Scanner.java b/src/main/java/com/chaudhuri/ooliteaddonscanner2/Scanner.java index 47c7a54..0864d42 100644 --- a/src/main/java/com/chaudhuri/ooliteaddonscanner2/Scanner.java +++ b/src/main/java/com/chaudhuri/ooliteaddonscanner2/Scanner.java @@ -442,10 +442,6 @@ public void run() { registry.processDependencies(); Verifier.verify(registry); - new File(outputDir, "equipment").mkdirs(); - new File(outputDir, "expansions").mkdirs(); - new File(outputDir, "ships").mkdirs(); - TemplateUtil.printExpansions(registry, outputDir, templateEngine); TemplateUtil.printEquipment(registry, outputDir, templateEngine); TemplateUtil.printShips(registry, outputDir, templateEngine); diff --git a/src/main/java/com/chaudhuri/ooliteaddonscanner2/TemplateUtil.java b/src/main/java/com/chaudhuri/ooliteaddonscanner2/TemplateUtil.java index f3bcb68..a2b1a8c 100644 --- a/src/main/java/com/chaudhuri/ooliteaddonscanner2/TemplateUtil.java +++ b/src/main/java/com/chaudhuri/ooliteaddonscanner2/TemplateUtil.java @@ -95,13 +95,15 @@ public static void printExpansions(Registry registry, File outputdir, TemplateEn throw new IllegalArgumentException(EXCEPTION_TEMPLATEENGINE_MUST_NOT_BE_NULL); } File expansionsDir = new File(outputdir, "expansions"); - expansionsDir.mkdirs(); for (Expansion expansion: registry.getExpansions()) { - File plantumlfile = new File(expansionsDir, expansion.getIdentifier()+PLANTUML_EXTENSION); + File expansionDir = new File(expansionsDir, expansion.getIdentifier()); + expansionDir.mkdirs(); + + File plantumlfile = new File(expansionDir, expansion.getIdentifier()+PLANTUML_EXTENSION); templateEngine.process(expansion, "expansionPlantUML.ftlh", plantumlfile); - PlantUMLUtil.generateDiagram(plantumlfile, expansionsDir); - templateEngine.process(expansion, "expansion.ftlh", new File(expansionsDir, expansion.getIdentifier()+HTML_EXTENSION)); + PlantUMLUtil.generateDiagram(plantumlfile, expansionDir); + templateEngine.process(expansion, "expansion.ftlh", new File(expansionDir, expansion.getIdentifier()+HTML_EXTENSION)); } } @@ -125,11 +127,12 @@ public static void printEquipment(Registry registry, File outputdir, TemplateEng if (templateEngine == null) { throw new IllegalArgumentException(EXCEPTION_TEMPLATEENGINE_MUST_NOT_BE_NULL); } - File equipmentDir = new File(outputdir, "equipment"); - equipmentDir.mkdirs(); + File expansionsDir = new File(outputdir, "expansions"); for (Equipment equipment: registry.getEquipment()) { - templateEngine.process(equipment, "equipment.ftlh", new File(equipmentDir, equipment.getIdentifier()+HTML_EXTENSION)); + File expansionDir = new File(expansionsDir, equipment.getExpansion().getIdentifier()); + expansionDir.mkdirs(); + templateEngine.process(equipment, "equipment.ftlh", new File(expansionDir, equipment.getIdentifier()+HTML_EXTENSION)); } } @@ -153,11 +156,12 @@ public static void printShips(Registry registry, File outputdir, TemplateEngine if (templateEngine == null) { throw new IllegalArgumentException(EXCEPTION_TEMPLATEENGINE_MUST_NOT_BE_NULL); } - File shipsDir = new File(outputdir, "ships"); - shipsDir.mkdirs(); + File expansionsDir = new File(outputdir, "expansions"); for (Ship ship: registry.getShips()) { - templateEngine.process(ship, "ship.ftlh", new File(shipsDir, ship.getIdentifier()+HTML_EXTENSION)); + File expansionDir = new File(expansionsDir, ship.getExpansion().getIdentifier()); + expansionDir.mkdirs(); + templateEngine.process(ship, "ship.ftlh", new File(expansionDir, ship.getIdentifier()+HTML_EXTENSION)); } } diff --git a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/equipment.ftlh b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/equipment.ftlh index 184c1b7..2bbd90b 100644 --- a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/equipment.ftlh +++ b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/equipment.ftlh @@ -21,7 +21,7 @@ Name${ name } Cost${ cost } deci-credits (divide by 10 to get credits) Tech Level${ techlevel } (available on ${ techlevel?number + 1 }+) - Expansion${ expansion.title } + Expansion${ expansion.title } Primeable<#if primeable>Yes<#else>No diff --git a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/expansion.ftlh b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/expansion.ftlh index 6d33095..a215b44 100644 --- a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/expansion.ftlh +++ b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/expansion.ftlh @@ -238,7 +238,7 @@ <#list equipment as e> - ${ e.name } + ${ e.name } ${ e.visible?string('yes', 'no') } ${ e.cost } ${ e.techlevel?number + 1 }+ @@ -259,7 +259,7 @@ <#list ships as ship> - ${ ship.name } + ${ ship.name } diff --git a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexAllByIdentifier.ftlh b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexAllByIdentifier.ftlh index 085cc7f..1f9bc8c 100644 --- a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexAllByIdentifier.ftlh +++ b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexAllByIdentifier.ftlh @@ -24,7 +24,13 @@ <#list allByIdentifier as ww> <#assign type><#if ww.type == "Ship">ships<#if ww.type == "Expansion">expansions<#if ww.type == "Equipment">equipment - ${ww.type}${ ww.identifier }${ ww.name }<#if ww.expansion??>${ ww.expansion.name }<#if ww.asWikipage??>Wiki Page<#else>No Wiki + + ${ww.type} + <#if ww.expansion??><#else>${ ww.identifier } + <#if ww.expansion??><#else>${ ww.name } + <#if ww.expansion??>${ ww.expansion.name } + <#if ww.asWikipage??>Wiki Page<#else>No Wiki + diff --git a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexEquipmentByName.ftlh b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexEquipmentByName.ftlh index 7ab6a98..aeb6531 100644 --- a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexEquipmentByName.ftlh +++ b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexEquipmentByName.ftlh @@ -24,8 +24,8 @@ <#list equipmentByName as equipment> - ${ equipment.name } - ${ equipment.expansion.name } + ${ equipment.name } + ${ equipment.expansion.name } ${ equipment.cost } ${ equipment.techlevel?number + 1 }+ diff --git a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexExpansionsByName.ftlh b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexExpansionsByName.ftlh index c55af43..8fe3bbe 100644 --- a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexExpansionsByName.ftlh +++ b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexExpansionsByName.ftlh @@ -25,7 +25,7 @@ <#list expansionsByName as expansion> - ${ expansion.title } + ${ expansion.title } <#if expansion.category??>${ expansion.category } <#if expansion.author??>${ expansion.author } <#if expansion.version??>${ expansion.version } diff --git a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexExpansionsByUploadDate.ftlh b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexExpansionsByUploadDate.ftlh index efb2c33..2a257c6 100644 --- a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexExpansionsByUploadDate.ftlh +++ b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexExpansionsByUploadDate.ftlh @@ -25,7 +25,7 @@ <#list expansionsByUploadDate as expansion> - ${ expansion.title } + ${ expansion.title } <#if expansion.category??>${ expansion.category } <#if expansion.author??>${ expansion.author } <#if expansion.version??>${ expansion.version } diff --git a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexShipsByName.ftlh b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexShipsByName.ftlh index 61a9597..60da7d4 100644 --- a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexShipsByName.ftlh +++ b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/indexShipsByName.ftlh @@ -23,8 +23,8 @@ <#list shipsByName as ship> - ${ ship.name } - ${ ship.expansion.name } + ${ ship.name } + ${ ship.expansion.name } ${ ship.features.roles!"" } <#if ship.template> diff --git a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/ship.ftlh b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/ship.ftlh index bea4569..e841e56 100644 --- a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/ship.ftlh +++ b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/ship.ftlh @@ -16,7 +16,7 @@ - +
Identifier${ identifier }
Name${ name }
Expansion${ expansion.title }
Expansion${ expansion.title }
<#if asWikipage??>

More on ${asWikipage}

diff --git a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/warnings.ftlh b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/warnings.ftlh index 1642048..3b8cfad 100644 --- a/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/warnings.ftlh +++ b/src/main/resources/com/chaudhuri/ooliteaddonscanner2/templates/warnings.ftlh @@ -23,7 +23,7 @@ <#list expansions as expansion> <#if expansion.warnings?has_content> -

${ expansion.title }

+

${ expansion.title }

    <#list expansion.warnings as w>
  • ${ w }
  • diff --git a/src/test/java/com/chaudhuri/ooliteaddonscanner2/RegistryTest.java b/src/test/java/com/chaudhuri/ooliteaddonscanner2/RegistryTest.java index bf6741c..e6e8f5d 100644 --- a/src/test/java/com/chaudhuri/ooliteaddonscanner2/RegistryTest.java +++ b/src/test/java/com/chaudhuri/ooliteaddonscanner2/RegistryTest.java @@ -124,13 +124,14 @@ public void testAddShip_Ship() { log.debug("ships in registry: {}", registry.getShips()); assertEquals(2, registry.getShips().size()); assertEquals(0, registry.getWarnings().size()); - + + // see whether we overwrite or add ships with same identifier Ship ship3 = new Ship("s2"); ship3.setExpansion(oxp); registry.addShip(ship3); log.debug("ships in registry: {}", registry.getShips()); - assertEquals(2, registry.getShips().size()); - assertEquals(1, registry.getWarnings().size()); + assertEquals(3, registry.getShips().size()); + assertEquals(0, registry.getWarnings().size()); } /** @@ -438,25 +439,29 @@ public void testAddGetEquipment_Equipment() { } equipment.setExpansion(expansion); - registry.addEquipment(equipment); + registry.addEquipment(equipment); // add blah assertEquals(1, registry.getEquipment().size()); assertEquals(equipment, registry.getEquipment().get(0)); Equipment equipment2 = new Equipment(); equipment2.setIdentifier("blah2"); equipment2.setExpansion(expansion); - registry.addEquipment(equipment2); + registry.addEquipment(equipment2); // add blah2 assertEquals(2, registry.getEquipment().size()); assertEquals(equipment, registry.getEquipment().get(0)); assertEquals(equipment2, registry.getEquipment().get(1)); + // we used to overwrite equipment with same IDs. This is no longer the case, + // so we expect equipment to pile up. Equipment equipment3 = new Equipment(); equipment3.setIdentifier("blah"); equipment3.setExpansion(expansion); - registry.addEquipment(equipment3); - assertEquals(2, registry.getEquipment().size()); - assertEquals(equipment3, registry.getEquipment().get(0)); - assertEquals(equipment2, registry.getEquipment().get(1)); + registry.addEquipment(equipment3); // add another blah + log.info("expansions: {}", registry.getEquipment()); + assertEquals(3, registry.getEquipment().size()); + assertEquals(equipment, registry.getEquipment().get(0)); + assertEquals(equipment3, registry.getEquipment().get(1)); + assertEquals(equipment2, registry.getEquipment().get(2)); } /** diff --git a/src/test/java/com/chaudhuri/ooliteaddonscanner2/TemplateUtilTest.java b/src/test/java/com/chaudhuri/ooliteaddonscanner2/TemplateUtilTest.java index 590b53a..8f9f665 100644 --- a/src/test/java/com/chaudhuri/ooliteaddonscanner2/TemplateUtilTest.java +++ b/src/test/java/com/chaudhuri/ooliteaddonscanner2/TemplateUtilTest.java @@ -285,7 +285,7 @@ public void testPrintExpansions4() throws Exception { assertTrue(outputdir.isDirectory()); TemplateUtil.printExpansions(registry, outputdir, templateEngine); - assertTrue(new File(outputdir, "expansions/myId.html").isFile()); + assertTrue(new File(outputdir, "expansions/myId/myId.html").isFile()); } /** @@ -312,7 +312,7 @@ public void testPrintExpansions5() throws Exception { assertTrue(outputdir.isDirectory()); TemplateUtil.printExpansions(registry, outputdir, templateEngine); - assertTrue(new File(outputdir, "expansions/myId.html").isFile()); + assertTrue(new File(outputdir, "expansions/myId/myId.html").isFile()); } /** @@ -395,7 +395,7 @@ public void testPrintEquipment4() throws Exception { assertTrue(outputdir.isDirectory()); TemplateUtil.printEquipment(registry, outputdir, templateEngine); - assertTrue(new File(outputdir, "equipment/myEquipment.html").isFile()); + assertTrue(new File(outputdir, "expansions/myExpansion/myEquipment.html").isFile()); } /** @@ -476,7 +476,7 @@ public void testPrintShips4() throws Exception { assertTrue(outputdir.isDirectory()); TemplateUtil.printShips(registry, outputdir, templateEngine); - assertTrue(new File(outputdir, "ships/myShip.html").isFile()); + assertTrue(new File(outputdir, "expansions/myExpansion/myShip.html").isFile()); } }