Skip to content

Commit

Permalink
Update Brreg Enhetsregister Test
Browse files Browse the repository at this point in the history
  • Loading branch information
oranheim committed Oct 7, 2024
1 parent c45d3b6 commit 76e9fca
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,25 @@ public void thatWorkerCollectEnhetsregisteret() throws InterruptedException {
@Test
void consumeLocalRawdataStore() throws Exception {
int pos = 0;
JsonParser jsonParser = JsonParser.createJsonParser();
var jsonParser = JsonParser.createJsonParser();
Function<byte[], String> toJson = (bytes) -> jsonParser.toPrettyJSON(jsonParser.fromJson(new String(bytes), ObjectNode.class));
var dashLine = IntStream.range(0, 80).mapToObj(i -> "-").reduce("", String::concat);

try (var client = ProviderConfigurator.configure(configuration.asMap(), configuration.evaluateToString("rawdata.client.provider"), RawdataClientInitializer.class)) {
try (var consumer = client.consumer(configuration.evaluateToString("rawdata.topic"))) {
RawdataMessage message;
while ((message = consumer.receive(1, TimeUnit.SECONDS)) != null && pos++ < 5) {
while ((message = consumer.receive(1, TimeUnit.SECONDS)) != null) { // && pos++ < 500
pos++;
var buf = new StringBuffer();
buf.append(IntStream.range(0, 80).mapToObj(i -> "-").reduce("", String::concat)).append("\n");
buf.append(dashLine).append("\n");
buf.append("position: ").append(message.position()).append("\n");
buf.append("feed-element:\n").append(toJson.apply(message.get("entry"))).append("\n");
buf.append("enhet-document (see feed-element -> href):\n").append(toJson.apply(message.get("event"))).append("\n");
System.out.print(buf);
}
}
}
System.out.println("Pos count: " + pos);
}

@Disabled
Expand Down Expand Up @@ -224,5 +227,4 @@ public void writeTargetConsumerSpec() throws IOException {
Files.writeString(targetPath.resolve("specs").resolve("enhetsregisteret-updates-spec.json"), specificationBuilder.serialize());
}


}

0 comments on commit 76e9fca

Please sign in to comment.