Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
Added new enums and new event HOLDER
Browse files Browse the repository at this point in the history
  • Loading branch information
Zenedith committed Mar 4, 2015
1 parent 7314e2b commit 4aabc2b
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 6 deletions.
30 changes: 30 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"motorcycle"
]
},
{
"name": "MOPED",
"values": [
"moped"
]
},
{
"name": "BUS",
"values": [
Expand Down Expand Up @@ -366,6 +372,12 @@
"KIA"
]
},
{
"name": "KAWASAKI",
"values": [
"KAWASAKI"
]
},
{
"name": "LEXUS",
"values": [
Expand Down Expand Up @@ -420,6 +432,12 @@
"RENAULT"
]
},
{
"name": "ROMET_MOTORS",
"values": [
"ROMET_MOTORS"
]
},
{
"name": "SEAT",
"values": [
Expand Down Expand Up @@ -474,6 +492,12 @@
"TRIUMPH"
]
},
{
"name": "TEMA",
"values": [
"TEMA"
]
},
{
"name": "URSUS",
"values": [
Expand Down Expand Up @@ -550,6 +574,12 @@
"co-owner"
]
},
{
"name": "HOLDER",
"values": [
"holder"
]
},
{
"name": "CHANGED_REGISTRATION_LOCATION",
"values": [
Expand Down
24 changes: 24 additions & 0 deletions lib/builder/event/holderEventBuilder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var assert = require('assert-plus');
var date = require('../../date');
var logger = require('../../logger/logger').logger;
var ChangeOwnerEventBuilder = require('../../model/response/event/changeOwnerEvent').ChangeOwnerEventBuilder;

var exports = {};

exports.build = function (event) {
logger.debug('build holder event:', event);

assert.object(event, 'event');
assert.string(event.type, 'event.type');
assert.string(event.createdAt, 'event.createdAt');
assert.string(event.description, 'event.description');

return new ChangeOwnerEventBuilder()
.withType(event.type)
.withCreatedAt(event.createdAt)
.withDescription(event.description)
.withOwnerType(event.ownerType)
.build();
};

module.exports = exports;
4 changes: 4 additions & 0 deletions lib/builder/eventsResponseBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var changeOwnerEventBuilder = require('./event/changeOwnerEventBuilder');
var inspectionEventBuilder = require('./event/inspectionEventBuilder');
var inspectonEventBuilder = require('./event/inspectonEventBuilder');
var coOwnerEventBuilder = require('./event/coOwnerEventBuilder');
var holderEventBuilder = require('./event/holderEventBuilder');
var changedRegistrationLocationEventBuilder = require('./event/changedRegistrationLocationEventBuilder');

var exports = {};
Expand Down Expand Up @@ -53,6 +54,9 @@ exports.build = function (map, callback) {
case 'CO_OWNER':
newEvent = coOwnerEventBuilder.build(event);
break;
case 'HOLDER':
newEvent = holderEventBuilder.build(event);
break;
case 'CHANGED_REGISTRATION_LOCATION':
newEvent = changedRegistrationLocationEventBuilder.build(event);
break;
Expand Down
1 change: 1 addition & 0 deletions lib/enum/eventEnum.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports.EventEnum = {
INSPECTON: 'INSPECTON',
INSPECTION: 'INSPECTION',
CO_OWNER: 'CO_OWNER',
HOLDER: 'HOLDER',
CHANGED_REGISTRATION_LOCATION: 'CHANGED_REGISTRATION_LOCATION',
UNKNOWN: 'UNKNOWN',
getEvent: function (type, events) {
Expand Down
3 changes: 3 additions & 0 deletions lib/enum/makeEnum.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports.MakeEnum = {
JAGUAR: 'JAGUAR',
YAMAHA: 'YAMAHA',
KIA: 'KIA',
KAWASAKI: 'KAWASAKI',
LEXUS: 'LEXUS',
LAND_ROVER: 'LAND_ROVER',
MERCEDES: 'MERCEDES',
Expand All @@ -31,6 +32,7 @@ module.exports.MakeEnum = {
PEUGEOT: 'PEUGEOT',
RENAULT: 'RENAULT',
ROLLS_ROYCE: 'ROLLS_ROYCE',
ROMET_MOTORS: 'ROMET_MOTORS',
SEAT: 'SEAT',
SKODA: 'SKODA',
SETRA: 'SETRA',
Expand All @@ -40,6 +42,7 @@ module.exports.MakeEnum = {
SUZUKI: 'SUZUKI',
TOYOTA: 'TOYOTA',
TRIUMPH: 'TRIUMPH',
TEMA: 'TEMA',
URSUS: 'URSUS',
VOLKSWAGEN: 'VOLKSWAGEN',
VOLVO: 'VOLVO',
Expand Down
1 change: 1 addition & 0 deletions lib/enum/variantEnum.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports.VariantEnum = function VariantEnum(type, kind) {
module.exports.VariantEnum.Type = {
CAR: 'CAR',
MOTORCYCLE: 'MOTORCYCLE',
MOPED: 'MOPED',
BUS: 'BUS',
TRACTOR: 'TRACTOR',
LIGHT_TRAILER: 'LIGHT_TRAILER',
Expand Down
2 changes: 1 addition & 1 deletion lib/resolver/event/eventOwnerTypeResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports.resolve = function (event, options) {
assert.object(event, 'event');
assert.object(options, 'options');

var owner = event.owner || event.coowner;
var owner = event.owner || event.coowner || event.holder;

if (!owner) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vehicle-history-model",
"version": "0.9.27",
"version": "0.9.28",
"description": "Vehicle history model.",
"main": "./index.js",
"dependencies": {
Expand Down Expand Up @@ -45,6 +45,6 @@
"node": ">=0.10.0"
},
"readmeFilename": "README.md",
"_id": "vehicle-history-model@0.9.27",
"_from": "vehicle-history-model@^0.9.27"
"_id": "vehicle-history-model@0.9.28",
"_from": "vehicle-history-model@^0.9.28"
}
29 changes: 28 additions & 1 deletion test/resolver/eventsResolverTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('events resolver builder test', function () {
description: 'First owner',
owner: 'private',
coowner: null,
holder: null,
location: 'wielkopolskie',
note: null,
mileage: null
Expand All @@ -26,6 +27,7 @@ describe('events resolver builder test', function () {
description: 'Abroad registration',
owner: null,
coowner: null,
holder: null,
location: null,
note: null,
mileage: null
Expand All @@ -35,6 +37,7 @@ describe('events resolver builder test', function () {
description: 'First registration',
owner: null,
coowner: null,
holder: null,
location: null,
note: null,
mileage: null
Expand All @@ -44,6 +47,7 @@ describe('events resolver builder test', function () {
description: 'Inspection (17.06.2014)',
owner: null,
coowner: null,
holder: null,
location: null,
note: null,
mileage: '177 000 km'
Expand All @@ -53,6 +57,7 @@ describe('events resolver builder test', function () {
description: 'Deregistration',
owner: null,
coowner: null,
holder: null,
location: null,
note: 'note',
mileage: null
Expand All @@ -62,6 +67,7 @@ describe('events resolver builder test', function () {
description: 'co-owner',
owner: null,
coowner: 'private',
holder: null,
location: null,
note: 'note',
mileage: null
Expand All @@ -71,9 +77,20 @@ describe('events resolver builder test', function () {
description: 'changed-registration-location',
owner: null,
coowner: null,
holder: null,
location: 'wielkopolskie',
note: 'note',
mileage: null
},
{ date: '17.06.2014',
type: 'holder',
description: 'holder',
owner: null,
coowner: null,
holder: 'private',
location: null,
note: 'note',
mileage: null
}
]
};
Expand All @@ -84,7 +101,7 @@ describe('events resolver builder test', function () {

var events = map.events;

expect(events).to.have.length(7);
expect(events).to.have.length(8);

expect(events).to.have.deep.property('[0].type', 'CHANGE_OWNER');
// expect(events).to.have.deep.property('[0].createdAt', '2012-06-13T00:00:00.000Z');
Expand Down Expand Up @@ -158,6 +175,16 @@ describe('events resolver builder test', function () {
expect(events).to.have.deep.property('[6].abroadRegistration', null);
expect(events).to.have.deep.property('[6].mileage', null);

expect(events).to.have.deep.property('[7].type', 'HOLDER');
// expect(events).to.have.deep.property('[7].createdAt', '2014-06-17T00:00:00.000Z');
expect(events).to.have.deep.property('[7].note', 'note');
expect(events).to.have.deep.property('[7].firstOwner', null);
expect(events).to.have.deep.property('[7].ownerType', 'PRIVATE');
expect(events).to.have.deep.property('[7].location', null);
expect(events).to.have.deep.property('[7].expireAt', null);
expect(events).to.have.deep.property('[7].abroadRegistration', null);
expect(events).to.have.deep.property('[7].mileage', null);

done();
});

Expand Down
32 changes: 31 additions & 1 deletion test/resolver/resolverTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ describe('resolver builder test', function () {
type: 'first-owner',
description: 'First owner',
owner: 'private',
coowner: null,
holder: null,
location: 'wielkopolskie',
note: null,
mileage: null
Expand All @@ -50,6 +52,8 @@ describe('resolver builder test', function () {
type: 'abroad-registration',
description: 'Abroad registration',
owner: null,
coowner: null,
holder: null,
location: null,
note: null,
mileage: null
Expand All @@ -58,6 +62,8 @@ describe('resolver builder test', function () {
type: 'first-registration',
description: 'First registration',
owner: null,
coowner: null,
holder: null,
location: null,
note: null,
mileage: null
Expand All @@ -66,6 +72,8 @@ describe('resolver builder test', function () {
type: 'inspection',
description: 'Inspection (17.06.2014)',
owner: null,
coowner: null,
holder: null,
location: null,
note: null,
mileage: '177 000 km'
Expand All @@ -74,6 +82,18 @@ describe('resolver builder test', function () {
type: 'deregistration',
description: 'Deregistration',
owner: null,
coowner: null,
holder: null,
location: null,
note: 'note',
mileage: null
},
{ date: '17.06.2014',
type: 'holder',
description: 'holder',
owner: null,
coowner: null,
holder: 'private',
location: null,
note: 'note',
mileage: null
Expand Down Expand Up @@ -117,7 +137,7 @@ describe('resolver builder test', function () {

expect(map).to.have.property('vin.value', 'ABC123456789DEF');

expect(events).to.have.length(5);
expect(events).to.have.length(6);

expect(events).to.have.deep.property('[0].type', 'CHANGE_OWNER');
// expect(events).to.have.deep.property('[0].createdAt', '2012-06-13T00:00:00.000Z');
Expand Down Expand Up @@ -170,6 +190,16 @@ describe('resolver builder test', function () {
expect(events).to.have.deep.property('[4].abroadRegistration', null);
expect(events).to.have.deep.property('[4].mileage', null);

expect(events).to.have.deep.property('[5].type', 'HOLDER');
// expect(events).to.have.deep.property('[5].createdAt', '2014-06-17T00:00:00.000Z');
expect(events).to.have.deep.property('[5].note', 'note');
expect(events).to.have.deep.property('[5].firstOwner', null);
expect(events).to.have.deep.property('[5].ownerType', 'PRIVATE');
expect(events).to.have.deep.property('[5].location', null);
expect(events).to.have.deep.property('[5].expireAt', null);
expect(events).to.have.deep.property('[5].abroadRegistration', null);
expect(events).to.have.deep.property('[5].mileage', null);

done();
});

Expand Down

0 comments on commit 4aabc2b

Please sign in to comment.