diff --git a/src/test/java/de/gwdg/metadataqa/marc/cli/parameters/MappingParametersTest.java b/src/test/java/de/gwdg/metadataqa/marc/cli/parameters/MappingParametersTest.java new file mode 100644 index 000000000..4d3e9c9dd --- /dev/null +++ b/src/test/java/de/gwdg/metadataqa/marc/cli/parameters/MappingParametersTest.java @@ -0,0 +1,99 @@ +package de.gwdg.metadataqa.marc.cli.parameters; + +import de.gwdg.metadataqa.marc.model.SolrFieldType; +import org.apache.commons.cli.ParseException; +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.*; + +public class MappingParametersTest { + + private MappingParameters parameters; + private String errorMessage; + + @Before + public void setUp() throws Exception { + parameters = null; + errorMessage = null; + } + + @Test + public void doExportSubfieldCodes() { + String[] arguments = new String[]{"--withSubfieldCodelists", "a-marc-file.mrc"}; + try { + parameters = new MappingParameters(arguments); + } catch (ParseException e) { + errorMessage = null; + } + assertNotNull("The parameters should not be null", parameters); + assertNull("The error messages should be null", errorMessage); + assertTrue(parameters.doExportSubfieldCodes()); + } + + @Test + public void doExportSelfDescriptiveCodes() { + String[] arguments = new String[]{"--withSelfDescriptiveCode", "a-marc-file.mrc"}; + try { + parameters = new MappingParameters(arguments); + } catch (ParseException e) { + errorMessage = null; + } + assertNotNull("The parameters should not be null", parameters); + assertNull("The error messages should be null", errorMessage); + assertTrue(parameters.doExportSelfDescriptiveCodes()); + } + + @Test + public void getSolrFieldType() { + String[] arguments = new String[]{"--solrFieldType", "marc-tags", "a-marc-file.mrc"}; + try { + parameters = new MappingParameters(arguments); + } catch (ParseException e) { + errorMessage = null; + } + assertNotNull("The parameters should not be null", parameters); + assertNull("The error messages should be null", errorMessage); + assertEquals(SolrFieldType.MARC, parameters.getSolrFieldType()); + } + + @Test + public void doExportFrbrFunctions() { + String[] arguments = new String[]{"--withFrbrFunctions", "a-marc-file.mrc"}; + try { + parameters = new MappingParameters(arguments); + } catch (ParseException e) { + errorMessage = null; + } + assertNotNull("The parameters should not be null", parameters); + assertNull("The error messages should be null", errorMessage); + assertTrue(parameters.doExportFrbrFunctions()); + } + + @Test + public void doExportCompilanceLevel() { + String[] arguments = new String[]{"--withCompilanceLevel", "a-marc-file.mrc"}; + try { + parameters = new MappingParameters(arguments); + } catch (ParseException e) { + errorMessage = null; + } + assertNotNull("The parameters should not be null", parameters); + assertNull("The error messages should be null", errorMessage); + assertTrue(parameters.doExportCompilanceLevel()); + } + + @Test + public void isWithLocallyDefinedFields() { + String[] arguments = new String[]{"--withLocallyDefinedFields", "a-marc-file.mrc"}; + try { + parameters = new MappingParameters(arguments); + } catch (ParseException e) { + errorMessage = null; + } + assertNotNull("The parameters should not be null", parameters); + assertNull("The error messages should be null", errorMessage); + assertTrue(parameters.isWithLocallyDefinedFields()); + } +} \ No newline at end of file