Skip to content

Commit

Permalink
Split test datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
joostfarla committed Oct 24, 2023
1 parent 47f350c commit c0fe670
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 33 deletions.
File renamed without changes.
16 changes: 16 additions & 0 deletions data/adr/model.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
objectTypes:
Address:
attributes:
id:
type: String
identifier: true
cardinality: 1
houseNumber:
type: Integer
cardinality: 1
houseNumberAddition:
type: String
cardinality: 0..1
postalCode:
type: String
cardinality: 0..1
File renamed without changes.
File renamed without changes.
20 changes: 2 additions & 18 deletions data/bld/model.yaml → data/city/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,12 @@ objectTypes:
inverseName: consistsOf
inverseCardinality: 0..*
hasMainAddress:
target: Address
target: adr:Address
cardinality: 1
inverseName: isMainAddressOf
inverseCardinality: 1
hasSubAddress:
target: Address
target: adr:Address
cardinality: 0..*
inverseName: isSubAddressOf
inverseCardinality: 1

Address:
attributes:
id:
type: String
identifier: true
cardinality: 1
houseNumber:
type: Integer
cardinality: 1
houseNumberAddition:
type: String
cardinality: 0..1
postalCode:
type: String
cardinality: 0..1
14 changes: 8 additions & 6 deletions data/geo/mapping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ targetModel:
location: ../data/geo/model.yaml

sourceModels:
bld:
location: ../data/bld/model.yaml
adr:
location: ../data/adr/model.yaml
city:
location: ../data/city/model.yaml

objectTypeMappings:
Construction:
sourceRoot: bld:Building
sourceRoot: city:Building
propertyMappings:
id:
pathMappings:
Expand All @@ -26,7 +28,7 @@ objectTypeMappings:
type: merge

Address:
sourceRoot: bld:Address
sourceRoot: adr:Address
propertyMappings:
id:
pathMappings:
Expand All @@ -43,7 +45,7 @@ objectTypeMappings:
# TODO: auto-create inverse mappings
isAddressOf:
pathMappings:
- path: isMainAddressOf
- path: isSubAddressOf
- path: isMainAddressOf/isPartOf
- path: isSubAddressOf/isPartOf
combiner:
type: coalesce
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class OrchestrateEngineIT {
private static final SpatialExtension SPATIAL_EXTENSION = new SpatialExtension();
private static ModelMapping MODEL_MAPPING;
@Mock
private DataRepository dataRepositoryMock;
private DataRepository adrRepositoryMock;

@Mock
private DataRepository cityRepositoryMock;

private OrchestrateEngine engine;

Expand All @@ -56,7 +59,8 @@ static void beforeAll() throws IOException {
void beforeEach() {
engine = OrchestrateEngine.builder()
.modelMapping(MODEL_MAPPING)
.source("bld", () -> dataRepositoryMock)
.source("adr", () -> adrRepositoryMock)
.source("city", () -> cityRepositoryMock)
.extension(SPATIAL_EXTENSION)
.build();
}
Expand All @@ -78,20 +82,29 @@ void fetch() {
.build())
.build();

when(dataRepositoryMock.findOne(any(ObjectRequest.class)))
when(adrRepositoryMock.findOne(any(ObjectRequest.class)))
.thenAnswer(invocation -> {
var objectType = ((ObjectRequest) invocation.getArgument(0)).getObjectType();

return switch (objectType.getName()) {
case "Address" -> Mono.just(Map.of("id", "A0001", "houseNumber", 23, "postalCode", "1234AB"));
default -> throw new IllegalStateException();
};
});

when(cityRepositoryMock.findOne(any(ObjectRequest.class)))
.thenAnswer(invocation -> {
var objectType = ((ObjectRequest) invocation.getArgument(0)).getObjectType();

return switch (objectType.getName()) {
case "Building" -> Mono.just(Map.of("id", "B0001", "area", 123, "geometry",
Map.of("type", "Polygon", "coordinates",
List.of(List.of(List.of(0, 0), List.of(10, 0), List.of(10, 10), List.of(0, 10), List.of(0, 0))))));
case "Address" -> Mono.just(Map.of("id", "A0001", "houseNumber", 23, "postalCode", "1234AB"));
default -> throw new IllegalStateException();
};
});

when(dataRepositoryMock.find(any(CollectionRequest.class)))
when(cityRepositoryMock.find(any(CollectionRequest.class)))
.thenAnswer(invocation -> {
var objectType = ((CollectionRequest) invocation.getArgument(0)).getObjectType();

Expand Down
8 changes: 6 additions & 2 deletions gateway/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ logging:
orchestrate:
mapping: ../data/geo/mapping.yaml
sources:
bld:
adr:
type: file
options:
dataPath: ../data/bld
dataPath: ../data/adr
city:
type: file
options:
dataPath: ../data/city
8 changes: 6 additions & 2 deletions gateway/src/test/resources/application-it.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
orchestrate:
mapping: ../data/geo/mapping.yaml
sources:
bld:
adr:
type: file
options:
dataPath: ../data/bld
dataPath: ../data/adr
city:
type: file
options:
dataPath: ../data/city

0 comments on commit c0fe670

Please sign in to comment.