Search in sources :

Example 11 with MarcFunctionContext

use of cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext in project RecordManager2 by moravianlibrary.

the class MarcScriptFactoryTest method test2.

@Test
public void test2() {
    MarcRecord record = parser.parseRecord(this.getClass().getResourceAsStream("/records/marcxml/MZK01-000087310.xml"));
    InputStream is1 = getClass().getResourceAsStream("/groovy/ExtendedMarc.groovy");
    InputStream is2 = getClass().getResourceAsStream("/groovy/BaseMarc.groovy");
    MappingScript<MarcFunctionContext> script = factory.create(is1, is2);
    MarcFunctionContext ctx = new MarcFunctionContext(record, metadataRecordFactory.getMetadataRecord(record));
    Map<String, Object> entries = script.parse(ctx);
    Collection<?> author2Roles = (Collection<?>) entries.get("author2_role");
    Assert.assertTrue(author2Roles.isEmpty());
}
Also used : InputStream(java.io.InputStream) MarcRecord(cz.mzk.recordmanager.server.marc.MarcRecord) Collection(java.util.Collection) MarcFunctionContext(cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 12 with MarcFunctionContext

use of cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext in project RecordManager2 by moravianlibrary.

the class BoundingBoxMarcFunctionsTest method testAustralia.

@Test
public void testAustralia() throws Exception {
    List<String> data = new ArrayList<String>();
    data.add("034 $aa $b6000000 $dE1023922  $eE1784848 $fN0023252 $gS0474141");
    MarcRecord record = MarcRecordFactory.recordFactory(data);
    String result = functions.getBoundingBox(new MarcFunctionContext(record, null, null));
    Assert.assertEquals(result, "102.65611111111112 -47.69472222222222 178.81333333333333 2.5477777777777777");
}
Also used : ArrayList(java.util.ArrayList) MarcRecord(cz.mzk.recordmanager.server.marc.MarcRecord) MarcFunctionContext(cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 13 with MarcFunctionContext

use of cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext in project RecordManager2 by moravianlibrary.

the class BoundingBoxMarcFunctionsTest method testSantiago.

@Test
public void testSantiago() throws Exception {
    List<String> data = new ArrayList<String>();
    data.add("034 $aa $b5100000 $dW0720810 $eW0475023 $fS0135757 $gS0345432");
    MarcRecord record = MarcRecordFactory.recordFactory(data);
    String result = functions.getBoundingBox(new MarcFunctionContext(record, null, null));
    Assert.assertEquals(result, "-72.13611111111112 -34.90888888888889 -47.83972222222222 -13.965833333333332");
}
Also used : ArrayList(java.util.ArrayList) MarcRecord(cz.mzk.recordmanager.server.marc.MarcRecord) MarcFunctionContext(cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 14 with MarcFunctionContext

use of cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext in project RecordManager2 by moravianlibrary.

the class MzkFormatFunctionsTest method photographyFormat.

public void photographyFormat() throws Exception {
    List<String> data = new ArrayList<String>();
    data.add("072 $a77 $xfotografie");
    String format = formatFunctions.getMZKFormat(new MarcFunctionContext(MarcRecordFactory.recordFactory(data)));
    Assert.assertEquals(format, "Photography");
}
Also used : ArrayList(java.util.ArrayList) MarcFunctionContext(cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext)

Example 15 with MarcFunctionContext

use of cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext in project RecordManager2 by moravianlibrary.

the class MzkFormatFunctionsTest method lawsOrOthersFormat.

public void lawsOrOthersFormat() throws Exception {
    List<String> data = new ArrayList<String>();
    data.add("000 -----nai-a22-----2a-4500");
    String format = formatFunctions.getMZKFormat(new MarcFunctionContext(MarcRecordFactory.recordFactory(data)));
    Assert.assertEquals(format, "LawsOrOthers");
}
Also used : ArrayList(java.util.ArrayList) MarcFunctionContext(cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext)

Aggregations

MarcFunctionContext (cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext)17 ArrayList (java.util.ArrayList)13 MarcRecord (cz.mzk.recordmanager.server.marc.MarcRecord)9 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)7 Test (org.testng.annotations.Test)7 InputStream (java.io.InputStream)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 MarcRecordImpl (cz.mzk.recordmanager.server.marc.MarcRecordImpl)1 Collection (java.util.Collection)1 List (java.util.List)1