-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
99 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
src/test/java/de/gwdg/metadataqa/marc/cli/parameters/MappingParametersTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |