Skip to content

Commit

Permalink
TEsting.
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Oct 6, 2024
1 parent 25d4134 commit a42ae53
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
24 changes: 24 additions & 0 deletions media-berlijn/src/test/java/nl/vpro/berlijn/domain/Util.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package nl.vpro.berlijn.domain;

import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;

import java.io.InputStream;
import java.nio.file.*;

@Log4j2
public class Util {

@SneakyThrows
public static InputStream getTable(String resource) {
Path path = Paths.get(System.getProperty("user.home")).toAbsolutePath().normalize().resolve("kafka/" + resource);
if (Files.exists(path)) {
log.info("Using {}", path);

return Files.newInputStream(path);
} else {
log.info("{} does not exist", path);
return Util.class.getResourceAsStream(resource);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.jupiter.params.provider.ValueSource;

import nl.vpro.berlijn.domain.Parser;
import nl.vpro.berlijn.domain.Util;
import nl.vpro.berlijn.util.kafka.KafkaDumpReader;


Expand All @@ -18,7 +19,8 @@ class AvailabilityTest {


public static Stream<byte[]> messages() {
return KafkaDumpReader.read(AvailabilityTest.class.getResourceAsStream("/availability/availability-messages.table")).map(KafkaDumpReader.Record::bytes).limit(1000);
return KafkaDumpReader.read(Util.getTable("/availability/availability-messages.table"))
.map(KafkaDumpReader.Record::bytes).limit(1000);
}

static Parser parser = Parser.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.junit.jupiter.params.provider.MethodSource;

import nl.vpro.berlijn.domain.Parser;
import nl.vpro.berlijn.domain.Util;
import nl.vpro.berlijn.util.kafka.KafkaDumpReader;


Expand All @@ -17,7 +18,7 @@ public class EPGTest {


public static Stream<byte[]> epg() {
return KafkaDumpReader.read(EPGTest.class.getResourceAsStream("/epg/epg-messages.table")).map(KafkaDumpReader.Record::bytes).limit(1000);
return KafkaDumpReader.read(Util.getTable(("/epg/epg-messages.table"))).map(KafkaDumpReader.Record::bytes).limit(1000);
}

static Parser parser = Parser.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import nl.vpro.berlijn.domain.Parser;
import nl.vpro.berlijn.domain.PomsMapper;
import nl.vpro.berlijn.domain.*;
import nl.vpro.berlijn.util.kafka.KafkaDumpReader;
import nl.vpro.domain.classification.ClassificationServiceLocator;
import nl.vpro.domain.media.*;
Expand Down Expand Up @@ -42,10 +41,10 @@ class ProductMetadataTest {

public static Stream<ProductMetadata> messages() {
return KafkaDumpReader
.read(ProductMetadataTest.class.getResourceAsStream("/productmetadata/product-metadata.table"))
.read(Util.getTable("/productmetadata/product-metadata.table"))
.map(KafkaDumpReader.Record::bytes)
.map(parser::parseProductMetadata)
.sorted(PomsMapper.randomOrder(random))
//.sorted(PomsMapper.randomOrder(random))
.limit(1000)
;

Expand Down

0 comments on commit a42ae53

Please sign in to comment.