Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
Code to make both MongoDB and Rest Service work
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeshi committed Aug 10, 2017
1 parent ed2b3f0 commit 229b50b
Show file tree
Hide file tree
Showing 12 changed files with 410 additions and 379 deletions.
60 changes: 20 additions & 40 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,34 @@
'use strict';

var path = require('path');

/* jshint -W106 */
module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

env: {
chrome: {
PLATFORM: 'CHROME'
},
firefox: {
PLATFORM: 'FIREFOX'
},
android: {
PLATFORM: 'ANDROID'
jshint: {
files: ['**/*.js', '.jshintrc', '!node_modules/**/*'],
options: {
jshintrc: '.jshintrc'
}
},

jshint: {
all: ['Gruntfile.js', 'features/step_definitions/*.js', 'features/support/*.js'],
cucumberjs: {
files: 'features',
options: {
node: true,
strict: true,
globalstrict: true,
'esversion':6
format: 'pretty',
tags:'@for_testing'
}
},

shell: {
mongo: {
command: 'mongod'
}
watch: {
files: ['<%= jshint.files %>', '**/*.feature'],
tasks: ['default']
},
})

exec: {
run_cucumber_tests: {
command: 'node ' + path.join('node_modules', 'cucumber', 'bin', 'cucumber.js -f pretty -t @for_testing')
}
}

});

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-shell-spawn');

grunt.registerTask('default', ['jshint', 'exec']);
grunt.registerTask('chrome', ['env:chrome', 'jshint', 'exec']);
grunt.registerTask('firefox', ['env:firefox', 'jshint', 'exec']);
//grunt.loadNpmTasks('grunt-contrib-jshint')
grunt.loadNpmTasks('grunt-cucumber')
grunt.loadNpmTasks('grunt-contrib-watch')

};
grunt.registerTask('default', ['cucumberjs'])
}
/* jshint +W106 */
30 changes: 30 additions & 0 deletions db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

var MongoClient = require('mongodb').MongoClient;

var DB = function DB(callback) {
var self = this;

this.db = null;

this.connect = function (user, pwd, host, db, callback) {
var connStr = "mongodb://";
connStr = connStr + user + ":";
connStr = connStr + pwd + "@";
connStr = connStr + host + "/";
connStr = connStr + db;
connStr = "mongodb://cucumber.utu.ai:27018/?ssl=true&certificatePreference=RootCACert:from_file&rootCAPath=ca.crt"
console.log(connStr);

MongoClient.connect(connStr, function (err, db) {
if (err) {
return callback.fail("DF:: ERROR Connection to the MongoDB" + err.message);
}
self.db = db;
callback();
});
}
callback();
}

exports.DB = DB;
8 changes: 2 additions & 6 deletions features/custom_algo.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ Feature: event triggers custom algo
| ALGO_MAP_REC |

@acceptance @custom_algo
Scenario Outline: Event field mutation triggers custom algo to run
When an Event of type <eType> containing an <matchKey> is received
Scenario: Event field mutation triggers custom algo to run
When an Event of type "Order" containing an "orderValue" is received
Then the associated Algo should fire

Examples:
| eType | matchKey |
| Order | orderValue |
29 changes: 19 additions & 10 deletions features/identity_get.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,25 @@ Background:
| GOLD_RECORD |

@acceptance
Scenario Outline: Updare received for Identity "match" field
Scenario: Updare received for Identity "match" field
Given request contains botKey with right access level
When an Identity search request by <matchField> for <medal> type is received
When an Identity search request by "tinId" for "tin" type is received
Then return the requested Identity record(s) or an appropriate response

Examples:
| matchField | medal |
| tinId | tin |
| email | bronze |
| browserId | silver |
| p + pid | gold |
| foreignId |
| phone |
@acceptance
Scenario: Updare received for Identity "match" field
Given request contains botKey with right access level
When an Identity search request by "email" for "bronze" type is received
Then return the requested Identity record(s) or an appropriate response

@acceptance
Scenario: Updare received for Identity "match" field
Given request contains botKey with right access level
When an Identity search request by "browserId" for "silver" type is received
Then return the requested Identity record(s) or an appropriate response

@acceptance
Scenario: Updare received for Identity "match" field
Given request contains botKey with right access level
When an Identity search request by "p + pid" for "gold" type is received
Then return the requested Identity record(s) or an appropriate response
34 changes: 25 additions & 9 deletions features/identity_post.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,32 @@ Scenario: Update received for Identity "custom" field
And push update to all medal Identity views
And push Identity rollup to related services

Scenario Outline: Updare received for Identity "match" field
When an Identity update is received with <matchField>
Scenario: Updare received for Identity "match" field
When an Identity update is received with "email"
Then review medal match when upserting an Identity tin record
And push update to all medal Identity views
And push impacted Identity rollup to related services

Examples:
| matchField |
| email |
| phone + first |
| browserId |
| p + pid |
| foreignId |
Scenario: Updare received for Identity "match" field
When an Identity update is received with "phone + first"
Then review medal match when upserting an Identity tin record
And push update to all medal Identity views
And push impacted Identity rollup to related services

Scenario: Updare received for Identity "match" field
When an Identity update is received with "browserId"
Then review medal match when upserting an Identity tin record
And push update to all medal Identity views
And push impacted Identity rollup to related services

Scenario: Updare received for Identity "match" field
When an Identity update is received with "p + pid"
Then review medal match when upserting an Identity tin record
And push update to all medal Identity views
And push impacted Identity rollup to related services

Scenario: Updare received for Identity "match" field
When an Identity update is received with "foreignId"
Then review medal match when upserting an Identity tin record
And push update to all medal Identity views
And push impacted Identity rollup to related services
54 changes: 54 additions & 0 deletions features/step_definitions/github_steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';

/* jshint -W061 */
// wtf jshint? eval can be harmful? But that is not eval, it's JSONPath#eval
var jsonPath = require('JSONPath').eval;
/* jshint +W061 */
var url = require('url')

var GithubStepsWrapper = function () {

this.World = require('../support/world.js').World;

// this.DB = require('../support/db.js').DB;

this.Given(/^there are Identity records as follows:$/, function (table, callback) {
this.connect('user', 'db', 'host',callback());
//this.conn('Rajesh');
});

this.When(/^a valid new Event is received$/, function (callback) {
var apiKey = "0475dbadc4cb410bbf562d605ea2cd47";
var context = {
platform: "sms",
platformId: "123-123-1234",
event: "test sms evet",
values: {
var1: "foo",
var2: "bar"
}
};

this.post(
"/track",
apiKey,
JSON.stringify(context),
callback()
);

//console.log(this.lastResponse);
});

this.Then(/^save the Event$/, function (callback) {
// var results = this.findAll();
console.log(this.lastResponse);
callback();
});

this.Then(/^update Identity with Event$/, function (callback) {
// express the regexp above with the code you wish you had
callback.pending();
});
}

module.exports = GithubStepsWrapper;
Loading

0 comments on commit 229b50b

Please sign in to comment.