Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests #11

Merged
merged 13 commits into from
Jan 23, 2025
25 changes: 17 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@ on:
pull_request:
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-and-publish:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Build Docker image
# HM TODO: add image name
run: docker build .
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 21
- name: Build and run tests
run: |
mvn clean install
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
- name: End to End tests setup
run: |
docker compose up -d elasticsearch
docker compose up planet-search
- name: End to End tests
run: |-
curl -s -X GET http://localhost:9200/points/_search?pretty -H 'Content-Type: application/json'

27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
planet-search:
build: .
network_mode: host
volumes:
- ./data:/app/data
environment:
- JAVA_OPTS=-Xmx2g -Xms2g
command:
- --es-address=http://localhost:9200
- --download
depends_on:
- elasticsearch

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.7.0
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- xpack.security.enrollment.enabled=false
ports:
- 9200:9200
volumes:
- esdata:/usr/share/elasticsearch/data

volumes:
esdata:
62 changes: 41 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,47 @@
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>il.org.osm.israelhiking.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>il.org.osm.israelhiking.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
19 changes: 0 additions & 19 deletions src/test/java/il/org/osm/israelhiking/AppTest.java

This file was deleted.

24 changes: 24 additions & 0 deletions src/test/java/il/org/osm/israelhiking/MinWayIdFinderTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package il.org.osm.israelhiking;

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

import org.junit.jupiter.api.Test;

public class MinWayIdFinderTest {

@Test
public void shouldFindMinWayWhenAddingBackwards() {
var finder = new MinWayIdFinder();
finder.addWayId(7);
finder.addWayId(3);
assertEquals(3, finder.minId);
}

@Test
public void shouldFindMinWayWhenAddingForward() {
var finder = new MinWayIdFinder();
finder.addWayId(3);
finder.addWayId(7);
assertEquals(3, finder.minId);
}
}
Loading