This repository has been archived by the owner on Mar 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code to make both MongoDB and Rest Service work
- Loading branch information
Showing
12 changed files
with
410 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.