-
Notifications
You must be signed in to change notification settings - Fork 0
Vi testar pull på main #7
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
Merged
The head ref may contain hidden characters: "Vi-testar-pull-p\u00E5-main"
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1 @@ | ||
| FAKTURA - EVTA Rental | ||
| Kund: eric | ||
| Att betala: 1700.0 kr | ||
| Betala till: | ||
|
|
||
| Bankgiro: 3492-232 | ||
| OCR: 0000000000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
|
|
||
| USE car_rental; | ||
|
|
||
| INSERT INTO cars (brand, model, registrationNumber, pricePerHour, pricePerDay) VALUES | ||
|
|
||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package org.example.entity; | ||
|
|
||
| public enum PaymentMethod { | ||
| Debit, | ||
| CASH, | ||
| INVOICE | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
|
|
||
| public class AppIT { | ||
| @Test | ||
| void itTest() { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package org.example; | ||
|
|
||
| import org.example.entity.Addon; | ||
| import org.example.entity.BookingType; | ||
| import org.example.entity.Car; | ||
| import org.example.service.BookingService; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class BookingServiceTest { | ||
|
|
||
| private final BookingService bookingService = new BookingService(); | ||
|
|
||
| @Test | ||
| void testCalculatePriceHourly() { | ||
| Car car = new Car("Volvo", "XC90", "ABC123", 500, 2000); | ||
| LocalDateTime start = LocalDateTime.of(2026, 1, 14, 10, 0); | ||
| LocalDateTime end = LocalDateTime.of(2026, 1, 14, 12, 0); // 2 timmar | ||
| List<Addon> addons = new ArrayList<>(); | ||
|
|
||
| double price = bookingService.calculatePrice(car, start, end, BookingType.HOURLY, addons); | ||
|
|
||
| // 2 timmar * 500 kr/timme = 1000 kr | ||
| assertThat(price).isEqualTo(1000); | ||
| } | ||
|
|
||
| @Test | ||
| void testCalculatePriceDaily() { | ||
| Car car = new Car("Volvo", "XC90", "ABC123", 500, 2000); | ||
| LocalDateTime start = LocalDateTime.of(2026, 1, 14, 10, 0); | ||
| LocalDateTime end = LocalDateTime.of(2026, 1, 16, 10, 0); // 2 dagar | ||
| List<Addon> addons = new ArrayList<>(); | ||
|
|
||
| double price = bookingService.calculatePrice(car, start, end, BookingType.DAILY, addons); | ||
|
|
||
| // 2 dagar * 2000 kr/dag = 4000 kr | ||
| assertThat(price).isEqualTo(4000); | ||
| } | ||
|
|
||
| @Test | ||
| void testCalculatePriceWithAddons() { | ||
| Car car = new Car("Volvo", "XC90", "ABC123", 500, 2000); | ||
| LocalDateTime start = LocalDateTime.of(2026, 1, 14, 10, 0); | ||
| LocalDateTime end = LocalDateTime.of(2026, 1, 14, 12, 0); // 2 timmar | ||
|
|
||
| List<Addon> addons = new ArrayList<>(); | ||
| Addon addon1 = new Addon("GPS", "GPS-navigator", 100); | ||
| addons.add(addon1); | ||
|
|
||
| double price = bookingService.calculatePrice(car, start, end, BookingType.HOURLY, addons); | ||
|
|
||
| // (2 timmar * 500 kr/timme) + 100 kr addon = 1100 kr | ||
| assertThat(price).isEqualTo(1100); | ||
| } | ||
|
|
||
| @Test | ||
| void testCalculatePriceMinimumOneHour() { | ||
| Car car = new Car("Volvo", "XC90", "ABC123", 500, 2000); | ||
| LocalDateTime start = LocalDateTime.of(2026, 1, 14, 10, 30); | ||
| LocalDateTime end = LocalDateTime.of(2026, 1, 14, 10, 45); // Samma timme | ||
| List<Addon> addons = new ArrayList<>(); | ||
|
|
||
| double price = bookingService.calculatePrice(car, start, end, BookingType.HOURLY, addons); | ||
|
|
||
| // Minimum 1 timme även om mindre än 1 timme valts | ||
| assertThat(price).isEqualTo(500); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
|
|
||
| package org.example; | ||
|
|
||
| import org.example.entity.Car; | ||
| import org.example.service.CarService; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class CarServiceTest { | ||
|
|
||
| private final CarService carService = new CarService(); | ||
|
Boppler12 marked this conversation as resolved.
|
||
|
|
||
| @Test | ||
| void testGetAllCarsReturnsNotNull() { | ||
| List<Car> cars = carService.getAllCars(); | ||
| assertThat(cars).isNotNull(); | ||
| } | ||
|
|
||
| @Test | ||
| void testGetAllCarsReturnsAList() { | ||
| List<Car> cars = carService.getAllCars(); | ||
| assertThat(cars).isInstanceOf(List.class); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.