Skip to content

Commit

Permalink
Merge pull request #21 from olech2412/19-implement-journeys
Browse files Browse the repository at this point in the history
new version 2.2.1 with bug fixes -> take a look at release-changes.md
  • Loading branch information
olech2412 authored Feb 20, 2024
2 parents 89684f9 + 01e6e22 commit 9b491f5
Show file tree
Hide file tree
Showing 17 changed files with 807 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.olech2412.adapter</groupId>
<artifactId>db-adapter-v6</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
<name>db-adapter-v6</name>
<description>This is an adapter for this rest-api: https://github.com/derhuerst/db-rest.
It can be used as a maven dependency and provides all models
Expand Down
23 changes: 16 additions & 7 deletions release-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@

## Description

This file contains the changes made in each release of the project since version 2.0.0
This file contains the changes made in each release of the project since version 2.2.0

In the following table you can see the versions and the release dates of the project.
Click on the version to get to the release changes.

| Version | Release Date |
|---------------|--------------|
| [2.0.0](#110) | unknown |

| Version | Release Date | Release Type |
|-----------------|--------------|--------------|
| [2.2.1](#2.2.1) | 20.02.2024 | Minor |
| [2.2.0](#2.2.0) | 20.02.2024 | Patch |
#TODO: Add the changes of the versions

## 2.0.0
## [2.2.1](#2.2.1) (20.02.2024) Patch Release

### Bugfixes

- Fixed a bug that the price class does not provide any getter or setter methods
- Fixed a bug that the Location class (for journeys) does not provide any getter or setter methods

## [2.2.0](#2.2.0) (20.02.2024) Minor Release

### Description
### Support for "journeys"

- Added support for "journeys" in the project
- Queries for journeys are now supported with the most features
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class APIConfiguration {

@Setter
private Proxy proxy;

public APIConfiguration() {
buildRequestList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ private Request getRequest(RequestPath requestPath) {

/**
* Perform the request
*
* @param request the request
* @return the result of the request
* @throws IOException if the request fails
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package de.olech2412.adapter.dbadapter.model.journey.sub;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
* Represents a location in the system.
*/
@Getter
@Setter
@ToString
public class Location {
/**
* The type of the location.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package de.olech2412.adapter.dbadapter.model.journey.sub;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
* Represents the price of a journey.
*/
@Getter
@Setter
@ToString
public class Price {
/**
* The amount of the price.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
public enum Mode {
BUS, TAXI, WATERCRAFT, TRAIN;

public String toValue() {
switch (this) {
case BUS: return "bus";
case TAXI: return "taxi";
case WATERCRAFT: return "watercraft";
case TRAIN: return "train";
}
return null;
}

public static Mode forValue(String value) throws IOException {
if (value.equals("bus")) return BUS;
if (value.equals("taxi")) return TAXI;
Expand All @@ -32,6 +22,20 @@ public static Mode forValue(String value) throws IOException {
throw new IOException("Cannot deserialize Mode");
}

public String toValue() {
switch (this) {
case BUS:
return "bus";
case TAXI:
return "taxi";
case WATERCRAFT:
return "watercraft";
case TRAIN:
return "train";
}
return null;
}

// custom ModeTypeAdapter for gson
public static class ModeTypeAdapter extends TypeAdapter<Mode> {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package de.olech2412.adapter.dbadapter.exception;

import org.junit.jupiter.api.Test;

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

class ErrorTest {

@Test
void creatingErrorShouldSetMessageAndCode() {
String message = "Error Message";
int code = 404;
Error error = new Error() {
@Override
public String getMessage() {
return message;
}

@Override
public int getCode() {
return code;
}
};

assertEquals(message, error.getMessage());
assertEquals(code, error.getCode());
}

@Test
void getErrorShouldReturnFormattedErrorMessage() {
String message = "Error Message";
int code = 404;
Error error = new Error() {
@Override
public String getMessage() {
return message;
}

@Override
public int getCode() {
return code;
}
};

String expected = "404: Error Message";
assertEquals(expected, error.getError());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package de.olech2412.adapter.dbadapter.model.journey;

import de.olech2412.adapter.dbadapter.model.journey.sub.Leg;
import de.olech2412.adapter.dbadapter.model.journey.sub.Price;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Collections;

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

public class JourneyTest {
private Journey journey;

@BeforeEach
void setUp() {
journey = new Journey();
}

@Test
void shouldSetAndGetType() {
String expectedType = "TestType";
journey.setType(expectedType);
assertEquals(expectedType, journey.getType());
}

@Test
void shouldSetAndGetTypeWhenTypeIsNull() {
journey.setType(null);
assertNull(journey.getType());
}

@Test
void shouldSetAndGetLegs() {
Leg expectedLeg = new Leg();
journey.setLegs(Collections.singletonList(expectedLeg));
assertEquals(Collections.singletonList(expectedLeg), journey.getLegs());
}

@Test
void shouldSetAndGetLegsWhenLegsIsNull() {
journey.setLegs(null);
assertNull(journey.getLegs());
}

@Test
void shouldSetAndGetRefreshToken() {
String expectedRefreshToken = "TestRefreshToken";
journey.setRefreshToken(expectedRefreshToken);
assertEquals(expectedRefreshToken, journey.getRefreshToken());
}

@Test
void shouldSetAndGetRefreshTokenWhenRefreshTokenIsNull() {
journey.setRefreshToken(null);
assertNull(journey.getRefreshToken());
}

@Test
void shouldSetAndGetPrice() {
Price expectedPrice = new Price();
journey.setPrice(expectedPrice);
assertEquals(expectedPrice, journey.getPrice());
}

@Test
void shouldSetAndGetPriceWhenPriceIsNull() {
journey.setPrice(null);
assertNull(journey.getPrice());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package de.olech2412.adapter.dbadapter.model.journey.sub;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

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

public class FeatureTest {
private Feature feature;

@BeforeEach
void setUp() {
feature = new Feature();
}

@Test
void shouldSetAndGetType() {
String expectedType = "TestType";
feature.setType(expectedType);
assertEquals(expectedType, feature.getType());
}

@Test
void shouldSetAndGetTypeWhenTypeIsNull() {
feature.setType(null);
assertNull(feature.getType());
}

@Test
void shouldSetAndGetProperties() {
Properties expectedProperties = new Properties();
feature.setProperties(expectedProperties);
assertEquals(expectedProperties, feature.getProperties());
}

@Test
void shouldSetAndGetPropertiesWhenPropertiesIsNull() {
feature.setProperties(null);
assertNull(feature.getProperties());
}

@Test
void shouldSetAndGetGeometry() {
Geometry expectedGeometry = new Geometry();
feature.setGeometry(expectedGeometry);
assertEquals(expectedGeometry, feature.getGeometry());
}

@Test
void shouldSetAndGetGeometryWhenGeometryIsNull() {
feature.setGeometry(null);
assertNull(feature.getGeometry());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package de.olech2412.adapter.dbadapter.model.journey.sub;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

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

public class GeometryTest {
private Geometry geometry;

@BeforeEach
void setUp() {
geometry = new Geometry();
}

@Test
void shouldSetAndGetType() {
String expectedType = "Point";
geometry.setType(expectedType);
assertEquals(expectedType, geometry.getType());
}

@Test
void shouldSetAndGetTypeWhenTypeIsNull() {
geometry.setType(null);
assertNull(geometry.getType());
}

@Test
void shouldSetAndGetCoordinates() {
List<Double> expectedCoordinates = Arrays.asList(1.0, 2.0);
geometry.setCoordinates(expectedCoordinates);
assertEquals(expectedCoordinates, geometry.getCoordinates());
}

@Test
void shouldSetAndGetCoordinatesWhenCoordinatesIsNull() {
geometry.setCoordinates(null);
assertNull(geometry.getCoordinates());
}

@Test
void shouldSetAndGetCoordinatesWhenCoordinatesIsEmpty() {
geometry.setCoordinates(new ArrayList<>());
assertTrue(geometry.getCoordinates().isEmpty());
}
}
Loading

0 comments on commit 9b491f5

Please sign in to comment.