Compare commits

..

10 commits

6 changed files with 42 additions and 20 deletions

View file

@ -1,11 +1,9 @@
stages: stages:
- package
- compile - compile
- test - test
- build - build
.setup-mvn: &setup-mvn
- chmod a+x mvnw
variables: variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
@ -14,18 +12,30 @@ cache:
- .m2/repository/ - .m2/repository/
- "**/target/" - "**/target/"
container:
stage: package
image: $CI_REGISTRY/ict/images/alpine/ci:latest
variables:
BUILDAH_ISOLATION: chroot
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
before_script:
- apk add buildah fuse-overlayfs
- buildah login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- buildah info
script:
- buildah build --tag $IMAGE_TAG -f Dockerfile
- buildah push $IMAGE_TAG
compile: compile:
stage: compile stage: compile
image: maven:3.8.6-openjdk-18 image: maven:3.8.6-openjdk-18
script: script:
- *setup-mvn
- ./mvnw clean compile - ./mvnw clean compile
test: test:
stage: test stage: test
image: markhobson/maven-chrome:jdk-18 image: markhobson/maven-chrome:jdk-18
script: script:
- *setup-mvn
- ./mvnw test - ./mvnw test
artifacts: artifacts:
name: "Surefire test reports from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" name: "Surefire test reports from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
@ -38,15 +48,13 @@ check:
stage: build stage: build
image: markhobson/maven-chrome:jdk-18 image: markhobson/maven-chrome:jdk-18
script: script:
- *setup-mvn - ./mvnw clean compile # dependency-check:aggregate
- ./mvnw clean compile
- ./mvnw sonar:sonar -Dsonar.projectKey=$SONAR_PROJECT -Dsonar.projectName=$SONAR_PROJECT -Dsonar.host.url=$SONAR_URL -Dsonar.token=$SONAR_TOKEN - ./mvnw sonar:sonar -Dsonar.projectKey=$SONAR_PROJECT -Dsonar.projectName=$SONAR_PROJECT -Dsonar.host.url=$SONAR_URL -Dsonar.token=$SONAR_TOKEN
build: build:
stage: build stage: build
image: maven:3.8.6-openjdk-18 image: maven:3.8.6-openjdk-18
script: script:
- *setup-mvn
- ./mvnw package -DskipTests - ./mvnw package -DskipTests
artifacts: artifacts:
name: "Maven artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" name: "Maven artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"

5
Dockerfile Normal file
View file

@ -0,0 +1,5 @@
FROM eclipse-temurin:17-jre-jammy
ARG JAR_FILE=app/target/*.jar
COPY ${JAR_FILE} app.jar
EXPOSE 8081
ENTRYPOINT ["java","-jar","/app.jar"]

View file

@ -9,15 +9,18 @@ import java.util.List;
@Component @Component
@Profile("stub") @Profile("stub")
public class ClubDatabaseDaoStub implements ClubDatabaseDao { public class ClubDatabaseDaoStub implements ClubDatabaseDao {
public static final String PILOT_ROLE = "PILOT";
public static final String BACKOFFICE_ROLE = "BACKOFFICE";
@Override @Override
public List<User> getUsers() { public List<User> getUsers() {
return Arrays.asList( return Arrays.asList(
new User(1L, "Kamila", "Spoustová", Arrays.asList("PILOT")), new User(1L, "Kamila", "Spoustová", Arrays.asList(PILOT_ROLE)),
new User(2L, "Naděžda", "Pavelková", Arrays.asList("PILOT")), new User(2L, "Naděžda", "Pavelková", Arrays.asList(PILOT_ROLE)),
new User(3L, "Silvie", "Hronová", Arrays.asList("PILOT")), new User(3L, "Silvie", "Hronová", Arrays.asList(PILOT_ROLE)),
new User(9L, "Miloš", "Korbel", Arrays.asList("PILOT", "BACKOFFICE")), new User(9L, "Miloš", "Korbel", Arrays.asList(PILOT_ROLE, BACKOFFICE_ROLE)),
new User(10L, "Petr", "Hrubec", Arrays.asList("PILOT", "BACKOFFICE")), new User(10L, "Petr", "Hrubec", Arrays.asList(PILOT_ROLE, BACKOFFICE_ROLE)),
new User(13L, "Michal", "Vyvlečka", Arrays.asList("BACKOFFICE")) new User(13L, "Michal", "Vyvlečka", Arrays.asList(BACKOFFICE_ROLE))
); );
} }
} }

12
pom.xml
View file

@ -93,5 +93,17 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>8.4.0</version>
<configuration>
<format>ALL</format>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View file

@ -51,10 +51,6 @@ public class FlightController {
@PostMapping("/flight/takeoff") @PostMapping("/flight/takeoff")
public ResponseEntity<Serializable> takeoff(@RequestBody FlightTakeoffTo start) { public ResponseEntity<Serializable> takeoff(@RequestBody FlightTakeoffTo start) {
// TODO tutorial-4.2: Remove this commented-out code
// for (int i = 0; i <= 10; i++) {
// System.out.println("Just printing i:" + i);
// }
log.debug("Start\n{}", start); log.debug("Start\n{}", start);
flightService.takeoff(start); flightService.takeoff(start);

View file

@ -32,12 +32,10 @@ public class CsvExportServiceImpl implements CsvExportService {
private final FlightRepository flightRepository; private final FlightRepository flightRepository;
private final String fileName; private final String fileName;
private String neverUsedField;
public CsvExportServiceImpl(FlightRepository flightRepository, @Value("${csv.export.flight.fileName}") String fileName) { public CsvExportServiceImpl(FlightRepository flightRepository, @Value("${csv.export.flight.fileName}") String fileName) {
this.flightRepository = flightRepository; this.flightRepository = flightRepository;
this.fileName = fileName; this.fileName = fileName;
this.neverUsedField = "redundant";
} }
@Override @Override