-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'v1.4.4' of 10.73.97.24:oecloud.io/feel into 1.x-release
This release fixes github issue 13, and also a bug in the decision table execution.
- Loading branch information
Showing
10 changed files
with
141 additions
and
13 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
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,4 @@ | ||
{ | ||
"final dec": "decision table(input expression list : ['test1','name'],outputs : \"outstring\",input values list : [[],[]],output values : [[]],rule list : [['\"Hiii\"','\"Ram\"','\"Hi ram\"'],['\"Hi\"','\"Rajesh\"','\"Hi rajesh\"']],id : 'final dec',hit policy : 'U')", | ||
"test1": "decision table(input expression list : ['msg'],outputs : \"out\",input values list : [[]],output values : [[]],rule list : [['\"Hi\"','\"Hiii\"'],['\"H\"','\"Hi\"']],id : 'test1',hit policy : 'U')" | ||
} |
31 changes: 31 additions & 0 deletions
31
test/date-time-expression/misc-date-and-time-related-tests.spec.js
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,31 @@ | ||
/* | ||
* | ||
* ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary), | ||
* Bangalore, India. All Rights Reserved. | ||
* | ||
*/ | ||
const chalk = require('chalk'); | ||
const chai = require('chai'); | ||
const FEEL = require('../../dist/feel'); | ||
|
||
const expect = chai.expect; | ||
|
||
describe(chalk.blue('misc date-and-time related tests...'), () => { | ||
it('should subtract months from last day of month correctly', (done) => { | ||
debugger; | ||
const text = 'date(date("2018-07-31") - duration("P1M")) = date("2018-06-30")'; | ||
try { | ||
const parsedGrammar = FEEL.parse(text); | ||
parsedGrammar.build() | ||
.then((result) => { | ||
expect(result).to.be.true; | ||
done(); | ||
}).catch((err) => { | ||
done(err); | ||
}); | ||
} catch (err) { | ||
done(err); | ||
} | ||
}); | ||
|
||
}); |
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,60 @@ | ||
/** | ||
* | ||
* ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary), | ||
* Bangalore, India. All Rights Reserved. | ||
* | ||
*/ | ||
|
||
var chai = require('chai'); | ||
var expect = chai.expect; | ||
var fs = require('fs'); | ||
var { createDecisionGraphAST, executeDecisionService } = require('../../index')().decisionService; | ||
|
||
var readJSON = (file) => JSON.parse(fs.readFileSync(file, { encoding: 'utf8' })); | ||
|
||
describe('decision table exposed in a service...', function () { | ||
it('should properly execute a decision table with is exposed through a service and one of its input expression references something in the graph', done => { | ||
var decisionMap = readJSON('./test/data/sample2.json'); | ||
var ast = createDecisionGraphAST(decisionMap); | ||
var payload = { | ||
"name": "Ram", | ||
"msg": "Hi" | ||
} | ||
|
||
executeDecisionService(ast, 'final dec', payload, 'foo') | ||
.then(result => { | ||
expect(result).to.be.object; | ||
expect(result).to.have.property('outstring'); | ||
expect(result.outstring).to.equal('Hi ram'); | ||
done(); | ||
}). | ||
catch(done); | ||
}); | ||
|
||
it('should error correctly when a decision table with a non-existent input expression is given', done => { | ||
var decisionMap = readJSON('./test/data/sample2.json'); | ||
|
||
var feelString = decisionMap['final dec']; | ||
|
||
decisionMap['final dec'] = feelString.replace('test1', 'test2'); | ||
expect(feelString.substr(feelString.indexOf('test'), 5)).to.equal('test1'); | ||
var feelString2 = decisionMap['final dec']; | ||
expect(feelString2.substr(feelString2.indexOf('test'), 5)).to.equal('test2'); | ||
var ast = createDecisionGraphAST(decisionMap); | ||
|
||
var payload = { | ||
"name": "Ram", | ||
"msg": "Hi" | ||
}; | ||
|
||
executeDecisionService(ast, 'final dec', payload, 'foo2') | ||
|
||
.then(() => { | ||
done(new Error('should not execute')); | ||
}) | ||
.catch(err => { | ||
expect(err.message).to.include('test2'); | ||
done(); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -59,4 +59,5 @@ describe('servicification tests...', function() { | |
|
||
// }); | ||
|
||
|
||
}); |
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