Skip to content

Commit

Permalink
- Handle case where visibility is prefixed by P or M when in miles.
Browse files Browse the repository at this point in the history
- Fix deployment actions to include tag.
  • Loading branch information
mivek committed May 31, 2022
1 parent 684c508 commit 383c154
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ jobs:
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE

- name: Retrieve the new version
id: get-version
uses: JActions/[email protected]

- name: Publish to Apache Maven Central
run: mvn clean -DskipTests deploy --settings .settings.xml -P release,ossrh
env:
Expand Down Expand Up @@ -60,6 +56,7 @@ jobs:
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ steps.get-version.outputs.version }}
prerelease: false
files: |
*.jar
3 changes: 3 additions & 0 deletions .github/workflows/manual-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.tag }}

- name: Download artifacts
uses: actions/download-artifact@v3
Expand All @@ -63,6 +65,7 @@ jobs:
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ github.event.inputs.tag }}
prerelease: false
files: |
*.jar
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public final class MainVisibilityNauticalMilesCommand implements Command {
/** Pattern for the main visibility in SM. */
private static final Pattern MAIN_VISIBILITY_SM_REGEX = Pattern.compile("^(\\d)*(\\s)?((\\d/\\d)?SM)$");
private static final Pattern MAIN_VISIBILITY_SM_REGEX = Pattern.compile("^([PM])?(\\d)*(\\s)?((\\d/\\d)?SM)$");

/**
* constructor.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.github.mivek.command.common;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;

/**
* @author Jean-Kevin KPADEY
*/
class MainVisibilityNauticalMilesCommandTest {

@Test
void testCanParse() {
MainVisibilityNauticalMilesCommand command = new MainVisibilityNauticalMilesCommand();
assertTrue(command.canParse("P6SM"));
assertTrue(command.canParse("M6SM"));
assertTrue(command.canParse("1 1/2SM"));
assertTrue(command.canParse("3/4SM"));
assertTrue(command.canParse("M6SM"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -764,4 +764,25 @@ void testParseWithRmkFcst() throws ParseException {
assertThat(taf.getTempos().get(0).getWeatherConditions().get(0).getPhenomenons(), hasSize(1));
assertEquals(Phenomenon.SNOW, taf.getTempos().get(0).getWeatherConditions().get(0).getPhenomenons().get(0));
}

@Test
void testParse() throws ParseException {
String code = """
TAF AMD KEWR 191303Z 1913/2018 09006KT 5SM -RA BR BKN007 OVC025
FM191600 17007KT P6SM BKN020
FM192100 26008KT P3SM SCT030 SCT050
FM200000 29005KT P4SM SCT050
FM200600 VRB03KT P9SM SCT050
""";

TAF taf = parser.parse(code);

assertEquals("5SM", taf.getVisibility().getMainVisibility());
assertEquals(4, taf.getFMs().size());
assertEquals("P6SM", taf.getFMs().get(0).getVisibility().getMainVisibility());
assertEquals("P3SM", taf.getFMs().get(1).getVisibility().getMainVisibility());
assertEquals("P4SM", taf.getFMs().get(2).getVisibility().getMainVisibility());
assertEquals("P9SM", taf.getFMs().get(3).getVisibility().getMainVisibility());
}

}

0 comments on commit 383c154

Please sign in to comment.