1
0
Fork 0

[DEV-5312] Revert schema change; filter by double underscore; add programid; add step field on rate delta

master
Austin Schaffer 2019-12-18 16:03:16 -05:00
commit e819edc53b
10 changed files with 160 additions and 505 deletions

View File

@ -48,7 +48,7 @@ const amqp_conf = createAmqpConfig( process.env );
const prom_conf = createPrometheusConfig( process.env ); const prom_conf = createPrometheusConfig( process.env );
const db_conf = createMongoConfig( process.env ); const db_conf = createMongoConfig( process.env );
const db = createMongoDB( db_conf ); const db = createMongoDB( db_conf );
const process_interval_ms = +( process.env.process_interval_ms || 10000 ); const process_interval_ms = +( process.env.PROCESS_INTERVAL_MS || 10000 );
const env = process.env.NODE_ENV || 'Unknown Environment'; const env = process.env.NODE_ENV || 'Unknown Environment';
const emitter = new EventEmitter(); const emitter = new EventEmitter();
const log = new StandardLogger( console, ts_ctr, env ); const log = new StandardLogger( console, ts_ctr, env );

View File

@ -81,6 +81,9 @@ export interface DeltaDocument
/** The document id */ /** The document id */
id: DocumentId, id: DocumentId,
/** The source program */
programId: string,
/** The entity name */ /** The entity name */
agentName: string, agentName: string,

View File

@ -45,6 +45,9 @@ export type DocumentMeta =
/** The document id */ /** The document id */
id: DocumentId, id: DocumentId,
/** The source program */
program: string,
/** The entity name */ /** The entity name */
entity_name: string, entity_name: string,

View File

@ -22,7 +22,7 @@
import { DeltaDao } from '../system/db/DeltaDao'; import { DeltaDao } from '../system/db/DeltaDao';
import { DocumentMeta } from '../document/Document'; import { DocumentMeta } from '../document/Document';
import { AmqpPublisher } from './AmqpPublisher'; import { AmqpPublisher } from './AmqpPublisher';
import { context } from '../error/ContextError'; import { context, hasContext } from '../error/ContextError';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { import {
DeltaType, DeltaType,
@ -109,6 +109,7 @@ export class DeltaProcessor
const ratedata = doc.ratedata || {}; const ratedata = doc.ratedata || {};
const meta = { const meta = {
id: doc.id, id: doc.id,
program: doc.programId,
entity_name: doc.agentName, entity_name: doc.agentName,
entity_id: +doc.agentEntityId, entity_id: +doc.agentEntityId,
startDate: doc.startDate, startDate: doc.startDate,
@ -133,15 +134,23 @@ export class DeltaProcessor
} ) } )
.catch( ( e: Error ) => .catch( ( e: Error ) =>
{ {
const context_error = context( if ( hasContext( e ) )
e, {
{ const combined_context: Record<string, any> = {};
doc_id: meta.id, const error_context = e.context;
quote_id: meta.id,
},
);
this._emitter.emit( 'error', context_error ); Object.keys( error_context ).forEach( ( key: string ) =>
{
combined_context[ key ] = error_context[ key ];
} );
combined_context[ 'doc_id' ] = meta.id;
combined_context[ 'quote_id' ] = meta.id;
e = context( e, combined_context );
}
this._emitter.emit( 'error', e );
return this._dao.setErrorFlag( meta.id ); return this._dao.setErrorFlag( meta.id );
} ); } );
} }

View File

@ -119,7 +119,8 @@ export class DeltaPublisher implements AmqpPublisher
{ {
doc_id: meta.id, doc_id: meta.id,
quote_id: meta.id, quote_id: meta.id,
delta: delta, type: delta.type,
delta_ts: delta.timestamp,
exchange: this._conn.getExchangeName(), exchange: this._conn.getExchangeName(),
} }
); );

View File

@ -139,7 +139,7 @@ export class V1MessageWriter implements MessageWriter
}, },
program: { program: {
Program: { Program: {
id: 'quote_server', id: meta.program,
version: '', version: '',
}, },
}, },
@ -196,12 +196,12 @@ export class V1MessageWriter implements MessageWriter
/** /**
* Format the data for avro by add type specifications to the data * Format the data for avro by add type specifications to the data
* *
* @param data - the data to format * @param data - the data to format
* @param depth - recursion depth * @param top_level - whether we are at the top level of the recursion
* *
* @return the formatted data * @return the formatted data
*/ */
setDataTypes( data: any, depth: number = 0 ): any setDataTypes( data: any, top_level: boolean = true ): any
{ {
let data_formatted: any = {}; let data_formatted: any = {};
@ -210,7 +210,7 @@ export class V1MessageWriter implements MessageWriter
case 'object': case 'object':
if ( data == null ) if ( data == null )
{ {
data_formatted = null; return null;
} }
else if ( Array.isArray( data ) ) else if ( Array.isArray( data ) )
{ {
@ -218,10 +218,10 @@ export class V1MessageWriter implements MessageWriter
data.forEach( ( datum ) => data.forEach( ( datum ) =>
{ {
arr.push( this.setDataTypes( datum, depth + 1 ) ); arr.push( this.setDataTypes( datum, false ) );
} ); } );
data_formatted = ( depth < 1 ) data_formatted = ( top_level )
? arr ? arr
: { 'array': arr }; : { 'array': arr };
} }
@ -231,36 +231,38 @@ export class V1MessageWriter implements MessageWriter
Object.keys( data).forEach( ( key: string ) => Object.keys( data).forEach( ( key: string ) =>
{ {
const datum = this.setDataTypes( data[ key ], depth + 1 ); // Do not include "private" keys
if ( key.startsWith( '__' ) )
{
return;
}
const datum = this.setDataTypes( data[ key ], false );
datum_formatted[ key ] = datum; datum_formatted[ key ] = datum;
} ); } );
data_formatted = ( depth < 1 ) data_formatted = ( top_level )
? datum_formatted ? datum_formatted
: { 'map': datum_formatted }; : { 'map': datum_formatted };
} }
break; break;
case 'boolean': case 'boolean':
return { 'bucket': { 'map': { 'boolean': data } } }; return { 'boolean': data };
case 'number': case 'number':
return { 'bucket': { 'map': { 'double': data } } }; return { 'double': data };
case 'string': case 'string':
return { 'bucket': { 'map': { 'string': data } } }; return { 'string': data };
case 'undefined': case 'undefined':
return { 'bucket': { 'map': null } }; return null;
}
if ( depth > 1 )
{
return { 'bucket': { 'map': data_formatted } };
} }
return data_formatted; return data_formatted;
} }
} }

View File

@ -123,16 +123,50 @@
"type": "map", "type": "map",
"values": [ "values": [
"null", "null",
"boolean",
"double",
"string",
{ {
"type": "array", "type": "array",
"items": "Data" "items": [
}, "null",
{ "boolean",
"type": "map", "double",
"values": "Data" "string",
{
"type": "array",
"items": [
"null",
"boolean",
"double",
"string",
{
"type": "array",
"items": [
"null",
"boolean",
"double",
"string"
]
}
]
},
{
"type": "map",
"values": [
"null",
"boolean",
"double",
"string",
{
"type": "map",
"values": [
"null",
"boolean",
"double",
"string"
]
}
]
}
]
} }
] ]
} }

View File

@ -40,6 +40,7 @@ export class MongoDeltaDao implements DeltaDao
/** The document fields to read */ /** The document fields to read */
readonly RESULT_FIELDS: Record<string, number> = { readonly RESULT_FIELDS: Record<string, number> = {
id: 1, id: 1,
programId: 1,
agentName: 1, agentName: 1,
agentEntityId: 1, agentEntityId: 1,
startDate: 1, startDate: 1,

View File

@ -428,6 +428,7 @@ describe( 'system.DeltaProcessor', () =>
const createdData = <UnixTimestamp>234234234; const createdData = <UnixTimestamp>234234234;
const doc = <DeltaDocument[]>[ { const doc = <DeltaDocument[]>[ {
id: <DocumentId>123, id: <DocumentId>123,
programId: 'mega',
agentName: entity_num, agentName: entity_num,
agentEntityId: entity_id, agentEntityId: entity_id,
startDate: createdData, startDate: createdData,
@ -447,6 +448,7 @@ describe( 'system.DeltaProcessor', () =>
}, },
{ {
id: <DocumentId>234, id: <DocumentId>234,
programId: 'mega',
agentName: entity_num, agentName: entity_num,
agentEntityId: entity_id, agentEntityId: entity_id,
startDate: createdData, startDate: createdData,
@ -471,6 +473,7 @@ describe( 'system.DeltaProcessor', () =>
entity_id: 4321, entity_id: 4321,
entity_name: 'Some Agency', entity_name: 'Some Agency',
id: 123, id: 123,
program: 'mega',
lastUpdate: 123123123, lastUpdate: 123123123,
startDate: 234234234, startDate: 234234234,
}, },
@ -483,6 +486,7 @@ describe( 'system.DeltaProcessor', () =>
entity_id: 4321, entity_id: 4321,
entity_name: 'Some Agency', entity_name: 'Some Agency',
id: 234, id: 234,
program: 'mega',
lastUpdate: 123123123, lastUpdate: 123123123,
startDate: 234234234, startDate: 234234234,
}, },
@ -548,6 +552,7 @@ describe( 'system.DeltaProcessor', () =>
const emitter = new EventEmitter(); const emitter = new EventEmitter();
const doc = <DeltaDocument[]>[ { const doc = <DeltaDocument[]>[ {
id: <DocumentId>123, id: <DocumentId>123,
programId: 'mega',
agentName: 'Some Agency', agentName: 'Some Agency',
agentEntityId: 4321, agentEntityId: 4321,
startDate: <UnixTimestamp>234234234, startDate: <UnixTimestamp>234234234,
@ -567,6 +572,7 @@ describe( 'system.DeltaProcessor', () =>
}, },
{ {
id: <DocumentId>234, id: <DocumentId>234,
programId: 'mega',
agentName: 'Some Agency', agentName: 'Some Agency',
agentEntityId: 4321, agentEntityId: 4321,
startDate: <UnixTimestamp>234234234, startDate: <UnixTimestamp>234234234,
@ -591,6 +597,7 @@ describe( 'system.DeltaProcessor', () =>
entity_id: 4321, entity_id: 4321,
entity_name: 'Some Agency', entity_name: 'Some Agency',
id: 123, id: 123,
program: 'mega',
lastUpdate: 123123123, lastUpdate: 123123123,
startDate: 234234234, startDate: 234234234,
}, },

View File

@ -95,59 +95,57 @@ describe( 'system.V1MessageWriter', () =>
{ {
label: 'Null array', label: 'Null array',
valid: true, valid: true,
delta_data: { foo: { 'array': [ delta_data: { foo: { 'array': [ null ] } },
{ 'bucket': { 'map': null } }
] } },
}, },
{ {
label: 'Boolean value', label: 'Boolean value',
valid: true, valid: true,
delta_data: { foo: { 'array': [ delta_data: { foo: { 'array': [
{ 'bucket': { 'map': { 'boolean': true } } }, { 'boolean': true },
] } }, ] } },
}, },
{ {
label: 'Simple string', label: 'Simple string',
valid: true, valid: true,
delta_data: { foo: { 'array': [ delta_data: { foo: { 'array': [
{ 'bucket': { 'map': { 'string': 'bar' } } }, { 'string': 'bar' },
{ 'bucket': { 'map': { 'string': 'baz' } } }, { 'string': 'baz' },
] } }, ] } },
}, },
{ {
label: 'Simple int', label: 'Simple int',
valid: true, valid: true,
delta_data: { foo: { 'array': [ delta_data: { foo: { 'array': [
{ 'bucket': { 'map': { 'double': 123 } } }, { 'double': 123 },
] } }, ] } },
}, },
{ {
label: 'Nested array', label: 'Nested array',
valid: true, valid: true,
delta_data: { foo: { 'array': [ delta_data: { foo: { 'array': [
{ 'bucket': { 'map': { 'array': [ { 'array': [
{ 'bucket': { 'map': { 'string': 'bar' } } }, { 'string': 'bar' },
] } } }, ] },
] } }, ] } },
}, },
{ {
label: 'Array with nulls', label: 'Array with nulls',
valid: true, valid: true,
delta_data: { foo: { 'array': [ delta_data: { foo: { 'array': [
{ 'bucket': { 'map': { 'string': 'bar' } } }, { 'string': 'bar' },
{ 'bucket': { 'map': { 'string': 'baz' } } }, { 'string': 'baz' },
{ 'bucket': { 'map': null } }, null,
] } }, ] } },
}, },
{ {
label: 'Nested Array with mixed values', label: 'Nested Array with mixed values',
valid: true, valid: true,
delta_data: { foo: { 'array': [ delta_data: { foo: { 'array': [
{ 'bucket': { 'map': { 'array': [ { 'array': [
{ 'bucket': { 'map': { 'string': 'bar' } } }, { 'string': 'bar' },
{ 'bucket': { 'map': { 'double': 123321 } } }, { 'double': 123321 },
{ 'bucket': { 'map': null } }, null,
] } } } ] }
] } }, ] } },
}, },
{ {
@ -168,180 +166,14 @@ describe( 'system.V1MessageWriter', () =>
label: 'Map objects', label: 'Map objects',
valid: true, valid: true,
delta_data: { 'foo': { 'array': [ delta_data: { 'foo': { 'array': [
{ 'bucket': { 'map': { 'map': { 'bar': { 'map': {
{ 'bucket': { 'map': { 'map': { 'baz': 'bar': { 'map': {
{ 'bucket': { 'map': { 'double': 1572903485000 } } } 'baz': { 'double': 1572903485000 },
} } } } } }
} } } } } }
] } }, ] } },
}, }
{
label: 'Arbitrary array/map depth',
valid: true,
delta_data: {
"a": { "array": [
{ "bucket": { "map": { "map": {
"b": { "bucket": { "map": { "array": [
{ "bucket": { "map": {
"string": "c"
} } },
{ "bucket": { "map": { "array": [
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "d"
} } },
{ "bucket": { "map": {
"map": {
"e": { "bucket": { "map": { "string": "f" } } },
"g": { "bucket": { "map": { "string": "h" } } },
"i": { "bucket": { "map": { "string": "j" } } },
"k": { "bucket": { "map": { "string": "l" } } },
"m": { "bucket": { "map": { "string": "n" } } }
}
} } },
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "o"
} } },
{ "bucket": { "map": {
"map": {
"p": { "bucket": { "map": {
"string": "q"
} } },
"r": { "bucket": { "map": {
"string": "s"
} } },
"t": { "bucket": { "map": {
"string": "u"
} } }
}
} } },
{ "bucket": { "map": { "array": [] } } },
{ "bucket": { "map": null } }
]
} } },
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "v"
} } },
{ "bucket": { "map": {
"map": {
"w": { "bucket": { "map": { "string": "x" } } },
"y": { "bucket": { "map": { "string": "z" } } }
}
} } },
{
"bucket": {
"map": {
"array": [
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "aa"
} } },
{ "bucket": { "map": {
"map": {
"ab": {
"bucket": {
"map": {
"string": "ac"
}
}
},
"ad": {
"bucket": {
"map": {
"string": "ae"
}
}
},
"af": {
"bucket": {
"map": {
"string": "ag"
}
}
},
"ah": {
"bucket": {
"map": {
"string": "ai"
}
}
}
}
} } },
{ "bucket": { "map": {
"array": []
} } },
{ "bucket": { "map": null } }
]
} } },
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "aj"
} } },
{ "bucket": { "map": {
"map": {
"ak": {
"bucket": { "map": {
"string": "al"
} }
},
"am": {
"bucket": { "map": {
"string": "an"
} }
},
"ao": {
"bucket": { "map": {
"string": "ap"
} }
}
}
} } },
{ "bucket": { "map": {
"array": []
} } },
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "q"
} } }
]
} } }
]
} } }
]
}
}
},
{ "bucket": { "map": {
"string": ""
} } }
]
} } }
]
} } },
{ "bucket": { "map": {
"string": ""
} } }
]
} } }
] } } },
{ "bucket": { "map": null } },
{ "bucket": { "map": { "boolean": false } } }
] } } }
} } } }
] }
},
},
].forEach( ( { label, delta_data, valid, expected } ) => ].forEach( ( { label, delta_data, valid, expected } ) =>
{ {
it( label, () => it( label, () =>
@ -408,7 +240,7 @@ describe( 'system.V1MessageWriter', () =>
label: 'Boolean Value', label: 'Boolean Value',
delta_data: { foo: [ true ] }, delta_data: { foo: [ true ] },
expected: { foo: { 'array': [ expected: { foo: { 'array': [
{ 'bucket': { 'map': { 'boolean': true } } }, { 'boolean': true },
] } }, ] } },
}, },
{ {
@ -418,8 +250,8 @@ describe( 'system.V1MessageWriter', () =>
'baz', 'baz',
] }, ] },
expected: { foo: { 'array': [ expected: { foo: { 'array': [
{ 'bucket': { 'map': { 'string': 'bar' } } }, { 'string': 'bar' },
{ 'bucket': { 'map': { 'string': 'baz' } } }, { 'string': 'baz' },
] } }, ] } },
}, },
{ {
@ -428,7 +260,7 @@ describe( 'system.V1MessageWriter', () =>
123 123
] }, ] },
expected: { foo: { 'array': [ expected: { foo: { 'array': [
{ 'bucket': { 'map': { 'double': 123 } } }, { 'double': 123 },
] } }, ] } },
}, },
{ {
@ -440,10 +272,10 @@ describe( 'system.V1MessageWriter', () =>
] ]
] }, ] },
expected: { foo: { 'array': [ expected: { foo: { 'array': [
{ 'bucket': { 'map': { 'array': [ { 'array': [
{ 'bucket': { 'map': { 'string': 'bar' } } }, { 'string': 'bar' },
{ 'bucket': { 'map': { 'string': 'baz' } } }, { 'string': 'baz' },
] } } }, ] },
] } }, ] } },
}, },
{ {
@ -458,13 +290,13 @@ describe( 'system.V1MessageWriter', () =>
], ],
] }, ] },
expected: { foo: { 'array': [ expected: { foo: { 'array': [
{ 'bucket': { 'map': { 'array': [ { 'array': [
{ 'bucket': { 'map': { 'array': [ { 'array': [
{ 'bucket': { 'map': { 'string': 'bar' } } }, { 'string': 'bar' },
{ 'bucket': { 'map': { 'double': 123 } } }, { 'double': 123 },
{ 'bucket': { 'map': null } }, null,
] } } }, ] },
] } } }, ] },
] } }, ] } },
}, },
{ {
@ -475,13 +307,13 @@ describe( 'system.V1MessageWriter', () =>
null null
] }, ] },
expected: { foo: { 'array': [ expected: { foo: { 'array': [
{ 'bucket': { 'map': { 'string': 'bar' } } }, { 'string': 'bar' },
{ 'bucket': { 'map': { 'string': 'baz' } } }, { 'string': 'baz' },
{ 'bucket': { 'map': null } }, null
] } }, ] } },
}, },
{ {
label: 'Nested array with mixed values', label: 'Nested Array with mixed values',
delta_data: { foo: [ delta_data: { foo: [
[ [
'bar', 'bar',
@ -490,15 +322,15 @@ describe( 'system.V1MessageWriter', () =>
] ]
] }, ] },
expected: { foo: { 'array': [ expected: { foo: { 'array': [
{ 'bucket': { 'map': { 'array': [ { 'array': [
{ 'bucket': { 'map': { 'string': 'bar' } } }, { 'string': 'bar' },
{ 'bucket': { 'map': { 'double': 123321 } } }, { 'double': 123321 },
{ 'bucket': { 'map': null } }, null,
] } } } ] },
] } }, ] } },
}, },
{ {
label: 'Nested map with mixed values', label: 'Nested Array with mixed values',
delta_data: { foo: [ delta_data: { foo: [
{ {
'bar': { 'bar': {
@ -510,256 +342,16 @@ describe( 'system.V1MessageWriter', () =>
}, },
] }, ] },
expected: { 'foo': { 'array': [ expected: { 'foo': { 'array': [
{ 'bucket': { 'map': { 'map': { 'bar': { 'map': {
{ 'bucket': { 'map': { 'map': { 'bar': { 'map': {
'wer': { 'bucket': { 'map': { 'wer': { 'string': 'qaz' },
'string': 'qaz' 'qwe': { 'double': 1572903485000 },
} } }, 'asd': { 'boolean': true },
'qwe': { 'bucket': { 'map': { 'zxc': null,
'double': 1572903485000 } },
} } }, } },
'asd': { 'bucket': { 'map': {
'boolean': true
} } },
'zxc': { 'bucket': { 'map': null } }
} } } }
} } } }
] } }, ] } },
}, },
{
label: 'Arbitrary array/map depth',
delta_data: {
"a": [
{
"b": [
"c",
[
[
"d",
{
"e": "f",
"g": "h",
"i": "j",
"k": "l",
"m": "n"
},
[
[
"o",
{
"p": "q",
"r": "s",
"t": "u"
},
[],
null
],
[
"v",
{
"w": "x",
"y": "z"
},
[
[
"aa",
{
"ab": "ac",
"ad": "ae",
"af": "ag",
"ah": "ai"
},
[],
null
],
[
"aj",
{
"ak": "al",
"am": "an",
"ao": "ap"
},
[],
[
"q"
]
]
],
""
]
],
""
]
],
null,
false
],
} ],
},
expected: {
"a": { "array": [
{ "bucket": { "map": { "map": {
"b": { "bucket": { "map": { "array": [
{ "bucket": { "map": {
"string": "c"
} } },
{ "bucket": { "map": { "array": [
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "d"
} } },
{ "bucket": { "map": {
"map": {
"e": { "bucket": { "map": { "string": "f" } } },
"g": { "bucket": { "map": { "string": "h" } } },
"i": { "bucket": { "map": { "string": "j" } } },
"k": { "bucket": { "map": { "string": "l" } } },
"m": { "bucket": { "map": { "string": "n" } } }
}
} } },
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "o"
} } },
{ "bucket": { "map": {
"map": {
"p": { "bucket": { "map": {
"string": "q"
} } },
"r": { "bucket": { "map": {
"string": "s"
} } },
"t": { "bucket": { "map": {
"string": "u"
} } }
}
} } },
{ "bucket": { "map": { "array": [] } } },
{ "bucket": { "map": null } }
]
} } },
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "v"
} } },
{ "bucket": { "map": {
"map": {
"w": { "bucket": { "map": { "string": "x" } } },
"y": { "bucket": { "map": { "string": "z" } } }
}
} } },
{
"bucket": {
"map": {
"array": [
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "aa"
} } },
{ "bucket": { "map": {
"map": {
"ab": {
"bucket": {
"map": {
"string": "ac"
}
}
},
"ad": {
"bucket": {
"map": {
"string": "ae"
}
}
},
"af": {
"bucket": {
"map": {
"string": "ag"
}
}
},
"ah": {
"bucket": {
"map": {
"string": "ai"
}
}
}
}
} } },
{ "bucket": { "map": {
"array": []
} } },
{ "bucket": { "map": null } }
]
} } },
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "aj"
} } },
{ "bucket": { "map": {
"map": {
"ak": {
"bucket": { "map": {
"string": "al"
} }
},
"am": {
"bucket": { "map": {
"string": "an"
} }
},
"ao": {
"bucket": { "map": {
"string": "ap"
} }
}
}
} } },
{ "bucket": { "map": {
"array": []
} } },
{ "bucket": { "map": {
"array": [
{ "bucket": { "map": {
"string": "q"
} } }
]
} } }
]
} } }
]
}
}
},
{ "bucket": { "map": {
"string": ""
} } }
]
} } }
]
} } },
{ "bucket": { "map": {
"string": ""
} } }
]
} } }
] } } },
{ "bucket": { "map": null } },
{ "bucket": { "map": { "boolean": false } } }
] } } }
} } } }
] }
},
},
].forEach( ( { label, delta_data, expected } ) => ].forEach( ( { label, delta_data, expected } ) =>
{ {
it( label, () => it( label, () =>
@ -780,11 +372,13 @@ describe( 'system.V1MessageWriter', () =>
} ); } );
it( 'Message is formatted correctly', () => it( 'Message is formatted correctly', () =>
{ {
const bucket = { foo: [ 'bar', 'baz' ] }; const bucket = { foo: [ 'bar', 'baz' ] };
const ratedata = {}; const ratedata = {};
const doc_id = <DocumentId>123; const doc_id = <DocumentId>123;
const program = 'mega';
const entity_name = 'Some Agency'; const entity_name = 'Some Agency';
const entity_id = 123; const entity_id = 123;
const startDate = <UnixTimestamp>345; const startDate = <UnixTimestamp>345;
@ -794,6 +388,7 @@ describe( 'system.V1MessageWriter', () =>
const encoder = createMockEncoderCtor( schema ); const encoder = createMockEncoderCtor( schema );
const meta = <DocumentMeta>{ const meta = <DocumentMeta>{
id: doc_id, id: doc_id,
program: program,
entity_name: entity_name, entity_name: entity_name,
entity_id: entity_id, entity_id: entity_id,
startDate: startDate, startDate: startDate,
@ -832,8 +427,8 @@ describe( 'system.V1MessageWriter', () =>
Data: { Data: {
bucket: { bucket: {
'foo': { 'array': [ 'foo': { 'array': [
{ 'bucket': { 'map': { 'string': 'bar' } } }, { 'string': 'bar' },
{ 'bucket': { 'map': { 'string': 'baz' } } }, { 'string': 'baz' },
] } ] }
}, },
}, },
@ -850,7 +445,7 @@ describe( 'system.V1MessageWriter', () =>
}, },
program: { program: {
Program: { Program: {
id: 'quote_server', id: program,
version: '', version: '',
}, },
}, },