@Test public void getSchema() { Road road = new Road(); Schema schema = SchemaBuilder.builder().intType(); road.setSchemas(Collections.singletonMap(1, new SchemaVersion(schema, 1, false))); store.put("road1", road); Schema result = underTest.schema("road1", 1); assertThat(result, is(schema)); }
public Schema schema(String roadName, int version) { return Mono .justOrEmpty(store.get(roadName)) .switchIfEmpty(throwRoadDoesNotExist(roadName)) .map(Road::getSchemas) .flatMap(schemas -> Mono.justOrEmpty(schemas.get(version))) .switchIfEmpty(throwSchemaDoesNotExist(roadName, version)) .map(SchemaVersion::getSchema) .block(); }
SchemaProvider { public Schema schema(String roadName, int version) { return Mono .justOrEmpty(store.get(roadName)) .switchIfEmpty(throwRoadDoesNotExist(roadName)) .map(Road::getSchemas) .flatMap(schemas -> Mono.justOrEmpty(schemas.get(version))) .switchIfEmpty(throwSchemaDoesNotExist(roadName, version)) .map(SchemaVersion::getSchema) .block(); } }
SchemaProvider { public Schema schema(String roadName, int version) { return Mono .justOrEmpty(store.get(roadName)) .switchIfEmpty(throwRoadDoesNotExist(roadName)) .map(Road::getSchemas) .flatMap(schemas -> Mono.justOrEmpty(schemas.get(version))) .switchIfEmpty(throwSchemaDoesNotExist(roadName, version)) .map(SchemaVersion::getSchema) .block(); }  }
SchemaProvider { public Schema schema(String roadName, int version) { return Mono .justOrEmpty(store.get(roadName)) .switchIfEmpty(throwRoadDoesNotExist(roadName)) .map(Road::getSchemas) .flatMap(schemas -> Mono.justOrEmpty(schemas.get(version))) .switchIfEmpty(throwSchemaDoesNotExist(roadName, version)) .map(SchemaVersion::getSchema) .block(); }  Schema schema(String roadName, int version); }
SchemaProvider { public Schema schema(String roadName, int version) { return Mono .justOrEmpty(store.get(roadName)) .switchIfEmpty(throwRoadDoesNotExist(roadName)) .map(Road::getSchemas) .flatMap(schemas -> Mono.justOrEmpty(schemas.get(version))) .switchIfEmpty(throwSchemaDoesNotExist(roadName, version)) .map(SchemaVersion::getSchema) .block(); }  Schema schema(String roadName, int version);  }