Skip to content

Commit

Permalink
Add integration test (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickackermann authored Nov 21, 2024
2 parents 72f845a + 21035a7 commit 1693bbe
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ch/geowerkstatt/lk2dxf/DxfWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void prepareDxfForWritingEntities(Collection<LayerMapping> layerMappings
() -> writeLineType("DashDotDot", 0.5, -0.25, 0.0, -0.25, 0.0, -0.25)),
() -> writeTable("LAYER", layers.values().toArray(ContentWriter[]::new)),
() -> writeTable("STYLE",
layerMappings.stream().map(LayerMapping::font).filter(f -> !f.isBlank()).map(f -> (ContentWriter) () -> writeStyle(f, f)).toArray(ContentWriter[]::new)),
layerMappings.stream().map(LayerMapping::font).filter(f -> !f.isBlank()).distinct().map(f -> (ContentWriter) () -> writeStyle(f, f)).toArray(ContentWriter[]::new)),
() -> writeTable("VIEW"),
() -> writeTable("UCS"),
() -> writeTable("APPID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ public List<LayerMapping> getLayerMappings() {
return Collections.unmodifiableList(layerMappings);
}

/**
* Get the {@link TransferDescription} with all models used by the {@link LayerMapping}s.
*/
public TransferDescription getTransferDescription() {
return transferDescription;
}

private static boolean matchesEnumSubValue(List<String> allowedValues, String attrValue) {
return allowedValues.stream().anyMatch(value -> attrValue.startsWith(value + "."));
}
Expand Down
14 changes: 13 additions & 1 deletion src/test/java/ch/geowerkstatt/lk2dxf/DxfWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public void writeEmptyDxf() throws Exception {
assertEquals("0\nSECTION\n2\nHEADER\n9\n$ACADVER\n1\nAC1021\n9\n$HANDSEED\n5\n3b9aca00\n9\n$INSUNITS\n70\n6\n0\nENDSEC\n0\nSECTION\n2\nCLASSES\n0\nENDSEC\n0\nSECTION\n2\nTABLES\n0\nTABLE\n2\nVPORT\n5\n1\n100\nAcDbSymbolTable\n70\n1\n0\nVPORT\n5\n2\n100\nAcDbSymbolTableRecord\n100\nAcDbViewportTableRecord\n2\n*ACTIVE\n70\n0\n0\nENDTAB\n0\nTABLE\n2\nLTYPE\n5\n3\n100\nAcDbSymbolTable\n70\n5\n0\nLTYPE\n5\n4\n100\nAcDbSymbolTableRecord\n100\nAcDbLinetypeTableRecord\n2\nByLayer\n70\n0\n72\n65\n73\n0\n40\n0\n0\nLTYPE\n5\n5\n100\nAcDbSymbolTableRecord\n100\nAcDbLinetypeTableRecord\n2\nByBlock\n70\n0\n72\n65\n73\n0\n40\n0\n0\nLTYPE\n5\n6\n100\nAcDbSymbolTableRecord\n100\nAcDbLinetypeTableRecord\n2\nContinuous\n70\n0\n72\n65\n73\n0\n40\n0\n0\nLTYPE\n5\n7\n100\nAcDbSymbolTableRecord\n100\nAcDbLinetypeTableRecord\n2\nDashed\n70\n0\n72\n65\n73\n2\n40\n0.75\n49\n0.5\n74\n0\n49\n-0.25\n74\n0\n0\nLTYPE\n5\n8\n100\nAcDbSymbolTableRecord\n100\nAcDbLinetypeTableRecord\n2\nDashDotDot\n70\n0\n72\n65\n73\n6\n40\n1.25\n49\n0.5\n74\n0\n49\n-0.25\n74\n0\n49\n0\n74\n0\n49\n-0.25\n74\n0\n49\n0\n74\n0\n49\n-0.25\n74\n0\n0\nENDTAB\n0\nTABLE\n2\nLAYER\n5\n9\n100\nAcDbSymbolTable\n70\n1\n0\nLAYER\n5\nA\n100\nAcDbSymbolTableRecord\n100\nAcDbLayerTableRecord\n2\n0\n6\nContinuous\n370\n25\n62\n0\n70\n0\n390\n0\n0\nENDTAB\n0\nTABLE\n2\nSTYLE\n5\nB\n100\nAcDbSymbolTable\n70\n0\n0\nENDTAB\n0\nTABLE\n2\nVIEW\n5\nC\n100\nAcDbSymbolTable\n70\n0\n0\nENDTAB\n0\nTABLE\n2\nUCS\n5\nD\n100\nAcDbSymbolTable\n70\n0\n0\nENDTAB\n0\nTABLE\n2\nAPPID\n5\nE\n100\nAcDbSymbolTable\n70\n1\n0\nAPPID\n5\nF\n100\nAcDbSymbolTableRecord\n100\nAcDbRegAppTableRecord\n2\nACAD\n70\n0\n0\nENDTAB\n0\nTABLE\n2\nDIMSTYLE\n5\n10\n100\nAcDbSymbolTable\n100\nAcDbDimStyleTable\n70\n0\n71\n1\n0\nENDTAB\n0\nTABLE\n2\nBLOCK_RECORD\n5\n11\n100\nAcDbSymbolTable\n70\n2\n0\nBLOCK_RECORD\n5\n12\n100\nAcDbSymbolTableRecord\n100\nAcDbBlockTableRecord\n2\n*Model_Space\n70\n0\n280\n1\n281\n0\n0\nBLOCK_RECORD\n5\n13\n100\nAcDbSymbolTableRecord\n100\nAcDbBlockTableRecord\n2\n*Paper_Space\n70\n0\n280\n1\n281\n0\n0\nENDTAB\n0\nENDSEC\n0\nSECTION\n2\nBLOCKS\n0\nBLOCK\n5\n14\n8\n0\n100\nAcDbEntity\n100\nAcDbBlockBegin\n2\n*Model_Space\n70\n0\n10\n0\n20\n0\n30\n0\n0\nENDBLK\n5\n15\n8\n0\n100\nAcDbEntity\n100\nAcDbBlockEnd\n0\nBLOCK\n5\n16\n8\n0\n100\nAcDbEntity\n100\nAcDbBlockBegin\n2\n*Paper_Space\n70\n0\n10\n0\n20\n0\n30\n0\n0\nENDBLK\n5\n17\n8\n0\n100\nAcDbEntity\n100\nAcDbBlockEnd\n0\nENDSEC\n0\nSECTION\n2\nENTITIES\n0\nENDSEC\n0\nSECTION\n2\nOBJECTS\n0\nDICTIONARY\n5\n18\n330\n0\n100\nAcDbDictionary\n281\n1\n3\nACAD_GROUP\n350\n19\n0\nDICTIONARY\n5\n19\n330\n18\n100\nAcDbDictionary\n281\n1\n0\nENDSEC\n0\nEOF\n", stringWriter.toString());
}

@Test
public void writeEmptyDxfWithLayerMappings() throws Exception {
var dxfWriter = new DxfWriter(testOutputWriter, 3, List.of(createTestLayerMapping("Layer_A"), createTestLayerMapping("Layer_B")), "APETHOWN");
dxfWriter.close();

assertEquals("999\nAPETHOWN\n0\nSECTION\n2\nHEADER\n9\n$ACADVER\n1\nAC1021\n9\n$HANDSEED\n5\n3b9aca00\n9\n$INSUNITS\n70\n6\n0\nENDSEC\n0\nSECTION\n2\nCLASSES\n0\nENDSEC\n0\nSECTION\n2\nTABLES\n0\nTABLE\n2\nVPORT\n5\n1\n100\nAcDbSymbolTable\n70\n1\n0\nVPORT\n5\n2\n100\nAcDbSymbolTableRecord\n100\nAcDbViewportTableRecord\n2\n*ACTIVE\n70\n0\n0\nENDTAB\n0\nTABLE\n2\nLTYPE\n5\n3\n100\nAcDbSymbolTable\n70\n5\n0\nLTYPE\n5\n4\n100\nAcDbSymbolTableRecord\n100\nAcDbLinetypeTableRecord\n2\nByLayer\n70\n0\n72\n65\n73\n0\n40\n0\n0\nLTYPE\n5\n5\n100\nAcDbSymbolTableRecord\n100\nAcDbLinetypeTableRecord\n2\nByBlock\n70\n0\n72\n65\n73\n0\n40\n0\n0\nLTYPE\n5\n6\n100\nAcDbSymbolTableRecord\n100\nAcDbLinetypeTableRecord\n2\nContinuous\n70\n0\n72\n65\n73\n0\n40\n0\n0\nLTYPE\n5\n7\n100\nAcDbSymbolTableRecord\n100\nAcDbLinetypeTableRecord\n2\nDashed\n70\n0\n72\n65\n73\n2\n40\n0.75\n49\n0.5\n74\n0\n49\n-0.25\n74\n0\n0\nLTYPE\n5\n8\n100\nAcDbSymbolTableRecord\n100\nAcDbLinetypeTableRecord\n2\nDashDotDot\n70\n0\n72\n65\n73\n6\n40\n1.25\n49\n0.5\n74\n0\n49\n-0.25\n74\n0\n49\n0\n74\n0\n49\n-0.25\n74\n0\n49\n0\n74\n0\n49\n-0.25\n74\n0\n0\nENDTAB\n0\nTABLE\n2\nLAYER\n5\n9\n100\nAcDbSymbolTable\n70\n3\n0\nLAYER\n5\nA\n100\nAcDbSymbolTableRecord\n100\nAcDbLayerTableRecord\n2\n0\n6\nContinuous\n370\n25\n62\n0\n70\n0\n390\n0\n0\nLAYER\n5\nB\n100\nAcDbSymbolTableRecord\n100\nAcDbLayerTableRecord\n2\nLayer_A\n6\nContinuous\n370\n25\n62\n1\n70\n0\n390\n0\n0\nLAYER\n5\nC\n100\nAcDbSymbolTableRecord\n100\nAcDbLayerTableRecord\n2\nLayer_B\n6\nContinuous\n370\n25\n62\n1\n70\n0\n390\n0\n0\nENDTAB\n0\nTABLE\n2\nSTYLE\n5\nD\n100\nAcDbSymbolTable\n70\n1\n0\nSTYLE\n5\nE\n100\nAcDbSymbolTableRecord\n100\nAcDbTextStyleTableRecord\n2\narial\n3\narial\n70\n0\n0\nENDTAB\n0\nTABLE\n2\nVIEW\n5\nF\n100\nAcDbSymbolTable\n70\n0\n0\nENDTAB\n0\nTABLE\n2\nUCS\n5\n10\n100\nAcDbSymbolTable\n70\n0\n0\nENDTAB\n0\nTABLE\n2\nAPPID\n5\n11\n100\nAcDbSymbolTable\n70\n1\n0\nAPPID\n5\n12\n100\nAcDbSymbolTableRecord\n100\nAcDbRegAppTableRecord\n2\nACAD\n70\n0\n0\nENDTAB\n0\nTABLE\n2\nDIMSTYLE\n5\n13\n100\nAcDbSymbolTable\n100\nAcDbDimStyleTable\n70\n0\n71\n1\n0\nENDTAB\n0\nTABLE\n2\nBLOCK_RECORD\n5\n14\n100\nAcDbSymbolTable\n70\n3\n0\nBLOCK_RECORD\n5\n15\n100\nAcDbSymbolTableRecord\n100\nAcDbBlockTableRecord\n2\n*Model_Space\n70\n0\n280\n1\n281\n0\n0\nBLOCK_RECORD\n5\n16\n100\nAcDbSymbolTableRecord\n100\nAcDbBlockTableRecord\n2\n*Paper_Space\n70\n0\n280\n1\n281\n0\n0\nBLOCK_RECORD\n5\n17\n100\nAcDbSymbolTableRecord\n100\nAcDbBlockTableRecord\n2\nTestSymbol\n70\n0\n280\n1\n281\n0\n0\nENDTAB\n0\nENDSEC\n0\nSECTION\n2\nBLOCKS\n0\nBLOCK\n5\n18\n8\n0\n100\nAcDbEntity\n100\nAcDbBlockBegin\n2\n*Model_Space\n70\n0\n10\n0\n20\n0\n30\n0\n0\nENDBLK\n5\n19\n8\n0\n100\nAcDbEntity\n100\nAcDbBlockEnd\n0\nBLOCK\n5\n1A\n8\n0\n100\nAcDbEntity\n100\nAcDbBlockBegin\n2\n*Paper_Space\n70\n0\n10\n0\n20\n0\n30\n0\n0\nENDBLK\n5\n1B\n8\n0\n100\nAcDbEntity\n100\nAcDbBlockEnd\n0\nBLOCK\n5\n1C\n8\n0\n100\nAcDbEntity\n100\nAcDbBlockBegin\n2\nTestSymbol\n70\n0\n10\n0\n20\n0\n30\n0\n0\nCIRCLE\n5\n1D\n100\nAcDbEntity\n8\n0\n100\nAcDbCircle\n10\n0\n20\n0\n40\n0.5\n0\nENDBLK\n5\n1E\n8\n0\n100\nAcDbEntity\n100\nAcDbBlockEnd\n0\nENDSEC\n0\nSECTION\n2\nENTITIES\n0\nENDSEC\n0\nSECTION\n2\nOBJECTS\n0\nDICTIONARY\n5\n1F\n330\n0\n100\nAcDbDictionary\n281\n1\n3\nACAD_GROUP\n350\n20\n0\nDICTIONARY\n5\n20\n330\n1F\n100\nAcDbDictionary\n281\n1\n0\nENDSEC\n0\nEOF\n", stringWriter.toString());
}

@Test
public void writeCircle() throws Exception {
try (var dxfWriter = new DxfWriter(testOutputWriter)) {
Expand Down Expand Up @@ -200,6 +208,10 @@ private IomObject[] createArcTestSegments(double pointRadius, double midPointRad
}

private Collection<LayerMapping> createTestLayerMappings() {
return List.of(new LayerMapping("Test", List.of(), LayerMapping.OutputType.SURFACE, "", 1, "", "", "", "", "TestSymbol", "", 0.25, 1.25, "arial", null));
return List.of(createTestLayerMapping("Test"));
}

private LayerMapping createTestLayerMapping(String layerName) {
return new LayerMapping(layerName, List.of(), LayerMapping.OutputType.SURFACE, "", 1, "", "", "", "", "TestSymbol", "", 0.25, 1.25, "arial", null);
}
}
159 changes: 159 additions & 0 deletions src/test/java/ch/geowerkstatt/lk2dxf/IntegrationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package ch.geowerkstatt.lk2dxf;

import ch.ehi.basics.logging.EhiLogger;
import ch.ehi.basics.logging.StdListener;
import ch.geowerkstatt.lk2dxf.mapping.ObjectMapper;
import ch.interlis.ili2c.Ili2cException;
import ch.interlis.iom.IomObject;
import ch.interlis.iom_j.xtf.XtfWriter;
import ch.interlis.iox.IoxException;
import ch.interlis.iox_j.EndBasketEvent;
import ch.interlis.iox_j.EndTransferEvent;
import ch.interlis.iox_j.ObjectEvent;
import ch.interlis.iox_j.StartBasketEvent;
import ch.interlis.iox_j.StartTransferEvent;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Random;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public final class IntegrationTest {
private static final String TEST_OUT_DIR = "src/test/data/Results/IntegrationTest/";

@BeforeAll
static void initAll() {
new File(TEST_OUT_DIR).mkdirs();

// Configure logging
Configurator.setRootLevel(Level.TRACE);
EhiLogger.getInstance().addListener(new EhiLogAdapter());
EhiLogger.getInstance().removeListener(StdListener.getInstance());
}

@Test
public void multipleFilesWithPerimeter() throws IOException, URISyntaxException, Ili2cException, IoxException {
// Clear output file
var outputFile = new File(TEST_OUT_DIR + "multipleFilesWithPerimeter" + ".dxf");
var logFile = new File(TEST_OUT_DIR + "multipleFilesWithPerimeter" + ".log");
if (outputFile.exists()) {
assertTrue(outputFile.delete(), "Failed to delete existing output file");
}
assertFalse(outputFile.exists());

// Generate input files
var files = new ArrayList<File>();
var objectCount = 2_000;
for (int i = 0; i < 3; i++) {
var file = new File(TEST_OUT_DIR + "multipleFilesWithPerimeter" + "_" + i + ".xtf");
files.add(file);
writeTestXTF(file, i * objectCount, objectCount);
}

// Run the main method
var perimeter = "Polygon ((2740857.55514180986210704 1256024.12385561061091721, 2607598.44303888687863946 1264279.11310092429630458, 2508533.20150150312110782 1106392.40145171224139631, 2578116.33859133720397949 1101537.89655045163817704, 2625680.80043338378891349 1178584.46284004743210971, 2706265.21925668558105826 1173867.3261284395121038, 2740857.55514180986210704 1101930.99127641879022121, 2795890.81677723582834005 1100751.7070985168684274, 2740857.55514180986210704 1256024.12385561061091721))";
Main.main(Stream.concat(files.stream().map(File::getAbsolutePath), Stream.of(outputFile.getAbsolutePath(), "--perimeter", perimeter, "--logfile", logFile.getAbsolutePath())).toArray(String[]::new));

// Check output
assertTrue(outputFile.exists());
assertTrue(outputFile.isFile());
assertTrue(outputFile.length() < 1_150_000, "Output file is too large <" + outputFile.length() + "> did the perimeter filter work?");
assertTrue(outputFile.length() > 10_000, "The output file is too small <" + outputFile.length() + "> it contains not much more than the default dxf content!");

assertTrue(logFile.exists());
assertTrue(logFile.isFile());
assertTrue(Files.readString(logFile.toPath()).contains("The output DXF file contains 2606 mapped objects"));
}

private void writeTestXTF(File file, int seed, int objectCount) throws IOException, URISyntaxException, Ili2cException, IoxException {
var objectMapper = new ObjectMapper();
var rand = new Random(seed);

XtfWriter writer = new XtfWriter(file, objectMapper.getTransferDescription());
try {
writer.write(new StartTransferEvent());
writer.write(new StartBasketEvent("SIA405_LKMap_2015_LV95.SIA405_LKMap", "BASKET1"));
for (int i = seed; i < objectCount + seed; i += 4) {
var x = rand.nextDouble() * 300_000 + 2510_000;
var y = rand.nextDouble() * 200_000 + 1085_000;
var size = rand.nextDouble() * 7000 + 3000;
writer.write(new ObjectEvent(createTextObject(i, x, y, "obj_" + (i + 1))));
writer.write(new ObjectEvent(createLineObject(i + 1, x, y, size)));
writer.write(new ObjectEvent(createFlaecheObject(i + 2, x, y)));
writer.write(new ObjectEvent(createPointObject(i + 3, x, y)));
}
writer.write(new EndBasketEvent());
writer.write(new EndTransferEvent());
} finally {
writer.close();
}
}

private final String[] precisionValues = new String[]{"genau", "unbekannt", "ungenau"};
private final String[] lineObjectTypeValues = new String[]{"Abwasser.Fernwirkkabel", "Abwasser.Haltung_Kanal", "Abwasser.Schutzrohr", "Elektrizitaet.AnkerStrebe", "Elektrizitaet.Trasse.oberirdisch", "Elektrizitaet.Trasse.unterirdisch", "Fernwaerme.Fernwirkkabel", "Fernwaerme.Trasse", "Gas.Fernwirkkabel", "Gas.Leitung", "Gas.Schutzrohr", "Kommunikation.Trasse.oberirdisch", "Kommunikation.Trasse.unterirdisch", "Wasser.Fernwirkkabel", "Wasser.Leitung", "Wasser.Schutzrohr", "weitereMedien.Fernwirkkabel", "weitereMedien.Leitung", "weitereMedien.Schutzrohr"};
private final String[] objectTypeValues = new String[]{"Abwasser", "Elektrizitaet", "Fernwaerme", "Gas", "Kommunikation", "Wasser", "weitereMedien"};
private final String[] objectStatusValues = new String[]{"ausser_Betrieb", "in_Betrieb", "tot", "unbekannt", "weitere"};

private IomObject createLineObject(int oid, double x, double y, double size) {
var rings = 4;
var angleCount = 7;
var segments = new ArrayList<IomObject>();
for (double r = size; r > 0.1; r -= size / rings) {
for (int i = 0; i < angleCount; i++) {
var angle = Math.TAU / angleCount * i;
var segment = IomObjectHelper.createCoord(Double.toString(x + r * Math.cos(angle)), Double.toString(y + r * Math.sin(angle)));
segments.add(segment);
}
}

var polyline = IomObjectHelper.createPolyline(segments.toArray(new IomObject[0]));
var rand = new Random(oid);
return IomObjectHelper.createIomObject("SIA405_LKMap_2015_LV95.SIA405_LKMap.LKLinie", "obj_" + oid,
o -> o.addattrobj("Linie", polyline),
o -> o.addattrvalue("Objektart", lineObjectTypeValues[rand.nextInt(lineObjectTypeValues.length)]),
o -> o.addattrvalue("Lagebestimmung", precisionValues[rand.nextInt(precisionValues.length)]),
o -> o.addattrvalue("Status", objectStatusValues[rand.nextInt(objectStatusValues.length)]),
o -> o.addattrvalue("Eigentuemer", "Keine_Angabe"));
}

private IomObject createFlaecheObject(int oid, double x, double y) {
var rand = new Random(oid);
return IomObjectHelper.createIomObject("SIA405_LKMap_2015_LV95.SIA405_LKMap.LKFlaeche", "obj_" + oid,
o -> o.addattrobj("Flaeche", IomObjectHelper.createRectangleGeometry(Double.toString(x), Double.toString(y), Double.toString(x - 1.5), Double.toString(y + 10))),
o -> o.addattrvalue("Objektart", objectTypeValues[rand.nextInt(objectTypeValues.length)]),
o -> o.addattrvalue("Lagebestimmung", precisionValues[rand.nextInt(precisionValues.length)]),
o -> o.addattrvalue("Status", objectStatusValues[rand.nextInt(objectStatusValues.length)]),
o -> o.addattrvalue("Eigentuemer", "Keine_Angabe"));
}

private IomObject createPointObject(int oid, double x, double y) {
var rand = new Random(oid);
return IomObjectHelper.createIomObject("SIA405_LKMap_2015_LV95.SIA405_LKMap.LKPunkt", "obj_" + oid,
o -> o.addattrobj("SymbolPos", IomObjectHelper.createCoord(Double.toString(x), Double.toString(y))),
o -> o.addattrvalue("Objektart", objectTypeValues[rand.nextInt(objectTypeValues.length)]),
o -> o.addattrvalue("Lagebestimmung", precisionValues[rand.nextInt(precisionValues.length)]),
o -> o.addattrvalue("Status", objectStatusValues[rand.nextInt(objectStatusValues.length)]),
o -> o.addattrvalue("Eigentuemer", "Keine_Angabe"));
}

private IomObject createTextObject(int oid, double x, double y, String objectRef) {
return IomObjectHelper.createIomObject("SIA405_LKMap_2015_LV95.SIA405_LKMap.LKObjekt_Text", "obj_" + oid,
o -> o.addattrobj("TextPos", IomObjectHelper.createCoord(Double.toString(x), Double.toString(y))),
o -> o.addattrvalue("TextOri", "90"),
o -> o.addattrvalue("TextHAli", "Left"),
o -> o.addattrvalue("TextVAli", "Base"),
o -> o.addattrvalue("Textinhalt", "obj_" + oid),
o -> o.addattrobj("LKObjektRef", IomObjectHelper.createIomObject("REF", null,
r -> r.setobjectrefoid(objectRef))));
}
}
11 changes: 11 additions & 0 deletions src/test/java/ch/geowerkstatt/lk2dxf/IomObjectHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import ch.interlis.iom.IomObject;
import ch.interlis.iom_j.Iom_jObject;

import java.util.function.Consumer;

public final class IomObjectHelper {
private IomObjectHelper() {
}
Expand Down Expand Up @@ -130,4 +132,13 @@ public static IomObject createArc(String a1, String a2, String c1, String c2, St
arc.setattrvalue("C3", c3);
return arc;
}

@SafeVarargs
public static IomObject createIomObject(String tag, String oid, Consumer<Iom_jObject>... attributeSetters) {
var iomObject = new Iom_jObject(tag, oid);
for (Consumer<Iom_jObject> attributeSetter : attributeSetters) {
attributeSetter.accept(iomObject);
}
return iomObject;
}
}
Loading

0 comments on commit 1693bbe

Please sign in to comment.