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 { ...@@ -24,10 +24,10 @@ class WikidataNormalizerTransformer extends Transform {
*/ */
private logger: LoggerInstance; private logger: LoggerInstance;
constructor(options, logger: LoggerInstance, wikidataProperties: WikidataProperties) { constructor(options) {
super(options); super(options);
this.logger = logger; this.logger = options.logger;
this.properties = wikidataProperties; this.properties = options.wikidataPropertiesInstance;
} }
/** /**
...@@ -69,8 +69,8 @@ class WikidataNormalizerTransformer extends Transform { ...@@ -69,8 +69,8 @@ class WikidataNormalizerTransformer extends Transform {
location: geohash.encode(lat, lon, 9), location: geohash.encode(lat, lon, 9),
}; };
} catch (err) { } catch (err) {
this.logger.error(`Transformer Error`); this.logger.warn(`Transformer Error`);
this.logger.error(err); this.logger.warn(err);
return callback(null); return callback(null);
} }
return callback(null, result); return callback(null, result);
......
...@@ -32,7 +32,7 @@ describe('Test WikiNormalizer', () => { ...@@ -32,7 +32,7 @@ describe('Test WikiNormalizer', () => {
}); });
it('Try to transform data', (done) => { 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 // listener to check output
normalizer.on('data', (data) => { normalizer.on('data', (data) => {
...@@ -46,14 +46,14 @@ describe('Test WikiNormalizer', () => { ...@@ -46,14 +46,14 @@ describe('Test WikiNormalizer', () => {
// build chunk // build chunk
const chunck = { const chunck = {
parsed: { parsed: {
data: new Buffer(fs.readFileSync(__dirname + '/fixtures/place.json')), data: Buffer.from(fs.readFileSync(__dirname + '/fixtures/place.json')),
}, },
}; };
normalizer.write(chunck); normalizer.write(chunck);
}); });
it('Try to transform in a pipline', (done) => { 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 mockReporter = new MockReporter();
const writeable = new MockWriteable({objectMode: true}); const writeable = new MockWriteable({objectMode: true});
...@@ -65,7 +65,7 @@ describe('Test WikiNormalizer', () => { ...@@ -65,7 +65,7 @@ describe('Test WikiNormalizer', () => {
// build chunk // build chunk
const chunck = { const chunck = {
parsed: { parsed: {
data: new Buffer(fs.readFileSync(__dirname + '/fixtures/place.json')), data: Buffer.from(fs.readFileSync(__dirname + '/fixtures/place.json')),
}, },
}; };
normalizer.write(chunck); normalizer.write(chunck);
...@@ -79,7 +79,7 @@ describe('Test WikiNormalizer', () => { ...@@ -79,7 +79,7 @@ describe('Test WikiNormalizer', () => {
}); });
it('Try to transform in a wrong data', (done) => { 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 mockReporter = new MockReporter();
const writeable = new MockWriteable({objectMode: true}); const writeable = new MockWriteable({objectMode: true});
......
Supports Markdown
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