Exemplo n.º 1
0
  // FIXME: fails!  needs MarcCombiningReader for mhld or at least a diff version of RawRecordReader
  @Test
  public void testMultMHLDsWithSameID() throws IOException {
    // bib134, multMhlds1
    String bibFilePath = testDataParentPath + File.separator + "mhldMergeBibs134.mrc";
    String mhldFilePath = testDataParentPath + File.separator + "mhldMergeMhlds1Mult.mrc";
    Map<String, Record> mergedRecs =
        MergeSummaryHoldings.mergeMhldsIntoBibRecordsAsMap(bibFilePath, mhldFilePath);

    Record mergedRec = mergedRecs.get("a1");
    assertEquals("Expected three 852", 3, mergedRec.getVariableFields("852").size());
    Set<String> expectedVals = new HashSet<String>();
    expectedVals.add("Location1");
    expectedVals.add("Location2");
    RecordTestingUtils.assertSubfieldHasExpectedValues(mergedRec, "852", 'b', expectedVals);

    expectedVals.clear();
    expectedVals.add("(month)");
    expectedVals.add("(season)");
    RecordTestingUtils.assertSubfieldHasExpectedValues(mergedRec, "853", 'b', expectedVals);

    assertEquals("Expected one 863", 2, mergedRec.getVariableFields("863").size());
    assertEquals("Expected one 866", 1, mergedRec.getVariableFields("866").size());
    // fail("Implement me");
    System.out.println("Test testMultMHLDsWithSameID() successful");
  }
Exemplo n.º 2
0
  /** test methods that return Map of ids to Records and no sysout stuff */
  @Test
  public void testGettingOutputAsMapOfRecords() throws IOException {
    String mhldRecFileName = testDataParentPath + File.separator + "summaryHld_1-1000.mrc";
    String bibRecFileName = testDataParentPath + File.separator + "u335.mrc";

    Map<String, Record> mergedRecs =
        MergeSummaryHoldings.mergeMhldsIntoBibRecordsAsMap(bibRecFileName, mhldRecFileName);

    junit.framework.Assert.assertEquals("results should have 1 record", 1, mergedRecs.size());
    String expId = "u335";
    assertTrue("Record with id " + expId + " should be in results", mergedRecs.containsKey(expId));

    Record resultRec = mergedRecs.get(expId);
    RecordTestingUtils.assertEqualsIgnoreLeader(mergedSummaryHoldingsOutputNoUmlaut, resultRec);
    System.out.println("Test testGettingOutputAsMapOfRecords() successful");
  }
Exemplo n.º 3
0
  /** code should output the unchanged bib records if no mhlds match */
  @Test
  public void testNoMatches() throws IOException {
    // bib46, mhld235
    String bibFilePath = testDataParentPath + File.separator + "mhldMergeBibs46.mrc";
    String mhldFilePath = testDataParentPath + File.separator + "mhldMergeMhlds235.mrc";
    Map<String, Record> mergedRecs =
        MergeSummaryHoldings.mergeMhldsIntoBibRecordsAsMap(bibFilePath, mhldFilePath);
    Set<String> mergedRecIds = mergedRecs.keySet();
    assertEquals(2, mergedRecIds.size());

    // result bibs should match the bib input because there was no merge
    String id = "a4";
    RecordTestingUtils.assertEquals(ALL_UNMERGED_BIBS.get(id), mergedRecs.get(id));
    id = "a6";
    RecordTestingUtils.assertEquals(ALL_UNMERGED_BIBS.get(id), mergedRecs.get(id));
    System.out.println("Test testNoMatches() successful");
  }
Exemplo n.º 4
0
  /** code should find a match when non-last bib matches last mhld */
  @Test
  public void testNonLastBibMatchesLastMhld() throws IOException {
    // bib46, mhld34
    String bibFilePath = testDataParentPath + File.separator + "mhldMergeBibs46.mrc";
    String mhldFilePath = testDataParentPath + File.separator + "mhldMergeMhlds34.mrc";
    Map<String, Record> mergedRecs =
        MergeSummaryHoldings.mergeMhldsIntoBibRecordsAsMap(bibFilePath, mhldFilePath);

    // there should be 2 results
    Set<String> mergedRecIds = mergedRecs.keySet();
    assertEquals(2, mergedRecIds.size());

    // result bib 6 only should have the mhld fields
    String id = "a4";
    RecordTestingUtils.assertEqualsIgnoreLeader(ALL_MERGED_BIB_RESULTS.get(id), mergedRecs.get(id));
    id = "a6";
    RecordTestingUtils.assertEqualsIgnoreLeader(ALL_UNMERGED_BIBS.get(id), mergedRecs.get(id));
    System.out.println("Test testLastBibMatchesNonLastMhld() successful");
  }