Skip to content

Commit

Permalink
Updated minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
sserhatacarr committed Feb 4, 2024
1 parent fadfa8b commit b98e496
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 20 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches:
- master

jobs:
qodana:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2023.3
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
31 changes: 31 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"

#Specify inspection profile for code analysis
profile:
name: qodana.starter

#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>

#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>

projectJDK: 21 #(Applied in CI/CD pipeline)

#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh

#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)

#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-jvm:latest
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.serhatacar.flightsearchapi.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Airport {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.serhatacar.flightsearchapi.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Flight {
@Id
@GeneratedValue (strategy = GenerationType.IDENTITY)
Expand All @@ -17,6 +22,6 @@ public class Flight {
@JoinColumn(name = "arrival_airport_id")
private Airport arrivalAirport;
private LocalDateTime departureDateTime;
private LocalDateTime returnDateTime;
private LocalDateTime arrivalDateTime;
private double price;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.serhatacar.flightsearchapi.repository;

import com.serhatacar.flightsearchapi.entity.Airport;
import com.serhatacar.flightsearchapi.entity.Flight;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface AirportRepository extends JpaRepository<Airport, Integer> {
List<Airport> findAirportsByArrivalFlightsContains(Flight flight);
List<Airport> findAirportsByDepartureFlightsContains(Flight flight);
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.serhatacar.flightsearchapi.repository;

import com.serhatacar.flightsearchapi.entity.Airport;
import com.serhatacar.flightsearchapi.entity.Flight;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface FlightRepository extends JpaRepository<Flight, Integer> {
List < Flight > findByArrivalAirport(Airport airport);
List < Flight > findByDepartureAirport(Airport airport);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
package com.serhatacar.flightsearchapi;

import com.serhatacar.flightsearchapi.entity.Flight;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

@SpringBootTest
import java.time.LocalDateTime;

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

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class FlightsearchapiApplicationTests {

@Test
void contextLoads() {
}
@Autowired
private TestRestTemplate restTemplate;

@Test
void testCreateFlight() {
Flight flight = new Flight();
flight.setDepartureDateTime(LocalDateTime.now());
flight.setArrivalDateTime(LocalDateTime.now().plusDays(1));
flight.setPrice(100.0);

ResponseEntity<Flight> response = restTemplate.postForEntity("/flights", flight, Flight.class);

assertEquals(HttpStatus.CREATED, response.getStatusCode());
assertEquals(flight.getPrice(), response.getBody().getPrice());
}


}
}

0 comments on commit b98e496

Please sign in to comment.