Skip to content

Commit

Permalink
feat: mock sfera communication and add example JP and SP (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
mghilardelli authored Oct 25, 2024
1 parent 11ed6ce commit d44a434
Show file tree
Hide file tree
Showing 60 changed files with 8,551 additions and 8,051 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# default reviewers
* @mghilardelli @Grodien
* @mghilardelli @Grodien @rawi-coding
16 changes: 16 additions & 0 deletions sfera-mock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,19 @@
- for SFERA e2e tests of mobile app

## Getting-Started


## Scenarios

- Recipient: 0085
- drivingMode: Read-Only
- architecture: BoardAdviceCalculation
- connectivity: Connected

| Train number | Result |
|--------------|--------------------------|
| 4816 | Zürich HB - Aarau <br/> |
| 7839 | Solothurn - Oberdorf SO |

TODO: 29137 Lenzburg - Luzern https://miro.com/app/board/uXjVKK4zJFk=/?moveToWidget=3458764596975113381&cot=14

7 changes: 6 additions & 1 deletion sfera-mock/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
<artifactId>jaxb-runtime</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down Expand Up @@ -129,7 +134,7 @@
<version>3.2.0</version>
<configuration>
<sources>
<source>${basedir}/src/main/resources/SFERA_2.01.xsd</source>
<source>${basedir}/src/main/resources/SFERA_3.0_custom.xsd</source>
</sources>
<xjbSources>
<xjbSource>${basedir}/src/main/resources/jaxb-bindings.xjb</xjbSource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Service
public class TenantService {

private static final Logger logger = LogManager.getLogger(TenantService.class);
private static final Logger log = LogManager.getLogger(TenantService.class);

private final TenantConfig tenantConfig;

Expand All @@ -25,7 +25,7 @@ public Tenant getByIssuerUri(String issuerUri) {
).findAny()
.orElseThrow(() -> new IllegalArgumentException("unknown tenant"));

logger.info(String.format("Got tenant '%s' with issuer URI '%s'", tenant.getName(), tenant.getIssuerUri()));
log.info(String.format("Got tenant '%s' with issuer URI '%s'", tenant.getName(), tenant.getIssuerUri()));

return tenant;
}
Expand Down

This file was deleted.

112 changes: 0 additions & 112 deletions sfera-mock/src/main/java/ch/sbb/sferamock/messages/SferaHandler.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ch.sbb.sferamock.messages.common;

public enum SferaErrorCodes {

SFERA_XSD_VERSION_NOT_SUPPORTED("2"),
INTENDED_RECIPIENT_NOT_ACTUAL_RECIPIENT("7"),
XML_SCHEMA_VIOLATION("13"),
ACTION_NOT_AUTHORIZED_FOR_USER("46"),
DATA_TEMPORARILY_UNAVAILABLE("48"),
COULD_NOT_PROCESS_DATA("50"),
INCONSISTENT_DATA("53");

final String code;

SferaErrorCodes(String code) {
this.code = code;
}

public String getCode() {
return code;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package ch.sbb.sferamock.messages.common;

import java.time.LocalDate;
import java.time.LocalDateTime;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public final class XmlDateHelper {

private XmlDateHelper() {
}

public static XMLGregorianCalendar toGregorianCalender(LocalDateTime localDateTime) {
try {
return DatatypeFactory.newInstance().newXMLGregorianCalendar(
localDateTime.getYear(), localDateTime.getMonth().getValue(), localDateTime.getDayOfMonth(),
localDateTime.getHour(), localDateTime.getMinute(), localDateTime.getSecond(),
DatatypeConstants.FIELD_UNDEFINED, 0);
} catch (DatatypeConfigurationException e) {
throw new RuntimeException(e);
}
}

public static XMLGregorianCalendar toGregorianCalender(LocalDate localDate) {
try {
return DatatypeFactory.newInstance().newXMLGregorianCalendarDate(
localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth(),
DatatypeConstants.FIELD_UNDEFINED);
} catch (DatatypeConfigurationException e) {
throw new RuntimeException(e);
}
}

public static LocalDate toLocalDate(XMLGregorianCalendar calendar) {
return LocalDate.of(calendar.getYear(), calendar.getMonth(), calendar.getDay());
}
}
Loading

0 comments on commit d44a434

Please sign in to comment.