Пример #1
0
 @Test
 public void pretendNormalize() throws IOException, FileStoreException, MetadataException {
   mock.getDataSetStore().importFile(MockFileStoreInput.sampleFile(), null);
   RecordMapping recordMapping = mock.getDataSetStore().getRecordMapping(mock.getMetadataPrefix());
   FileStore.MappingOutput mo = mock.getDataSetStore().createMappingOutput(recordMapping, null);
   mo.recordDiscarded();
   mo.recordNormalized();
   mo.recordNormalized();
   Assert.assertEquals("Should be one file", 1, mock.getSpecDirectory().listFiles().length);
   mo.close(false);
   mock.getDataSetStore().setRecordMapping(recordMapping);
   Assert.assertEquals("Should be two files", 2, mock.getSpecDirectory().listFiles().length);
   recordMapping = mock.getDataSetStore().getRecordMapping(mock.getMetadataPrefix());
   Assert.assertEquals("Mapping should contain facts", 1, recordMapping.getRecordsDiscarded());
   Assert.assertEquals("Mapping should contain facts", 2, recordMapping.getRecordsNormalized());
 }
Пример #2
0
 @Test
 public void manipulateMapping() throws IOException, FileStoreException, MetadataException {
   mock.getDataSetStore().importFile(MockFileStoreInput.sampleFile(), null);
   Assert.assertEquals(
       "Spec should be the same", MockFileStoreFactory.SPEC, mock.getDataSetStore().getSpec());
   RecordMapping recordMapping = mock.getDataSetStore().getRecordMapping(mock.getMetadataPrefix());
   Assert.assertEquals(
       "Prefixes should be the same", mock.getMetadataPrefix(), recordMapping.getPrefix());
   log.info("Mapping created with prefix " + recordMapping.getPrefix());
   MappingModel mappingModel = new MappingModel();
   mappingModel.setRecordMapping(recordMapping);
   mappingModel.setFact("/some/path", "value");
   mock.getDataSetStore().setRecordMapping(recordMapping);
   Assert.assertEquals("Should be two files", 2, mock.getSpecDirectory().listFiles().length);
   recordMapping = mock.getDataSetStore().getRecordMapping(mock.getMetadataPrefix());
   Assert.assertEquals("Should have held fact", "value", recordMapping.getFact("/some/path"));
 }