Commit ac3121e4 authored by tobinski's avatar tobinski
Browse files

Update signature of the normalizer and tests

parent 10419744
......@@ -24,10 +24,10 @@ class WikidataNormalizerTransformer extends Transform {
*/
private logger: LoggerInstance;
constructor(options, logger: LoggerInstance, wikidataProperties: WikidataProperties) {
constructor(options) {
super(options);
this.logger = logger;
this.properties = wikidataProperties;
this.logger = options.logger;
this.properties = options.wikidataPropertiesInstance;
}
/**
......@@ -69,8 +69,8 @@ class WikidataNormalizerTransformer extends Transform {
location: geohash.encode(lat, lon, 9),
};
} catch (err) {
this.logger.error(`Transformer Error`);
this.logger.error(err);
this.logger.warn(`Transformer Error`);
this.logger.warn(err);
return callback(null);
}
return callback(null, result);
......
......@@ -32,7 +32,7 @@ describe('Test WikiNormalizer', () => {
});
it('Try to transform data', (done) => {
const normalizer = new WikidataNormalizerTransformer({objectMode: true}, coreMock.getLogger(), wikidataTimeProperties);
const normalizer = new WikidataNormalizerTransformer({objectMode: true, logger: coreMock.getLogger(), wikidataPropertiesInstance: wikidataTimeProperties});
// listener to check output
normalizer.on('data', (data) => {
......@@ -46,14 +46,14 @@ describe('Test WikiNormalizer', () => {
// build chunk
const chunck = {
parsed: {
data: new Buffer(fs.readFileSync(__dirname + '/fixtures/place.json')),
data: Buffer.from(fs.readFileSync(__dirname + '/fixtures/place.json')),
},
};
normalizer.write(chunck);
});
it('Try to transform in a pipline', (done) => {
const normalizer = new WikidataNormalizerTransformer({objectMode: true}, coreMock.getLogger(), wikidataTimeProperties);
const normalizer = new WikidataNormalizerTransformer({objectMode: true, logger: coreMock.getLogger(), wikidataPropertiesInstance: wikidataTimeProperties});
const mockReporter = new MockReporter();
const writeable = new MockWriteable({objectMode: true});
......@@ -65,7 +65,7 @@ describe('Test WikiNormalizer', () => {
// build chunk
const chunck = {
parsed: {
data: new Buffer(fs.readFileSync(__dirname + '/fixtures/place.json')),
data: Buffer.from(fs.readFileSync(__dirname + '/fixtures/place.json')),
},
};
normalizer.write(chunck);
......@@ -79,7 +79,7 @@ describe('Test WikiNormalizer', () => {
});
it('Try to transform in a wrong data', (done) => {
const normalizer = new WikidataNormalizerTransformer({objectMode: true}, coreMock.getLogger(), wikidataTimeProperties);
const normalizer = new WikidataNormalizerTransformer({objectMode: true, logger: coreMock.getLogger(), wikidataPropertiesInstance: wikidataTimeProperties});
const mockReporter = new MockReporter();
const writeable = new MockWriteable({objectMode: true});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment