-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into expression_boolean
- Loading branch information
Showing
11 changed files
with
174 additions
and
49 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
**I'm submitting a ...** (check one with "x") | ||
``` | ||
[] bug report => search github for a similar issue or PR before submitting | ||
[] enhancement request | ||
[] feature request | ||
[] support request | ||
[] general question | ||
``` | ||
|
||
**Current behavior (how does the issue manifest):** | ||
|
||
**Expected behavior:** | ||
|
||
**Minimal steps to reproduce the problem (not required if feature enhancement):** | ||
|
||
**What is the motivation / use case for changing the behavior?** | ||
|
||
**Please tell us about your environment (Operating system, docker version, browser & verison if webui, etc):** | ||
|
||
**Flogo version (CLI & contrib/lib. If unknown, leave empty or state unknown):** 0.X.X | ||
|
||
**Additional information you deem important (e.g. issue happens only occasionally):** |
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,14 @@ | ||
**What kind of change does this PR introduce?** (check one with "x") | ||
``` | ||
[] Bugfix | ||
[] Feature | ||
[] Code style update (formatting, local variables) | ||
[] Refactoring (no functional changes, no api changes) | ||
[] Other... Please describe: | ||
``` | ||
|
||
**Fixes**: # | ||
|
||
**What is the current behavior?** | ||
|
||
**What is the new behavior?** |
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
29 changes: 29 additions & 0 deletions
29
core/mapper/exprmapper/function/string/equalsignorecase/equalsignorecase.go
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,29 @@ | ||
package equalsignorecase | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/TIBCOSoftware/flogo-lib/core/mapper/exprmapper/expression/function" | ||
"github.com/TIBCOSoftware/flogo-lib/logger" | ||
) | ||
|
||
var log = logger.GetLogger("equalsIgnoreCase-function") | ||
|
||
type EqualsIgnoreCase struct { | ||
} | ||
|
||
func init() { | ||
function.Registry(&EqualsIgnoreCase{}) | ||
} | ||
|
||
func (s *EqualsIgnoreCase) GetName() string { | ||
return "equalsIgnoreCase" | ||
} | ||
|
||
func (s *EqualsIgnoreCase) GetCategory() string { | ||
return "string" | ||
} | ||
func (s *EqualsIgnoreCase) Eval(str, str2 string) bool { | ||
log.Debugf(`Reports whether "%s" equels "%s" with ignore case`, str, str2) | ||
return strings.EqualFold(str, str2) | ||
} |
42 changes: 42 additions & 0 deletions
42
core/mapper/exprmapper/function/string/equalsignorecase/equalsignorecase_test.go
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,42 @@ | ||
package equalsignorecase | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/TIBCOSoftware/flogo-lib/core/mapper/exprmapper/expression" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
var s = &EqualsIgnoreCase{} | ||
|
||
func TestStaticFunc_Starts_with(t *testing.T) { | ||
final1 := s.Eval("TIBCO FLOGO", "TIBCO") | ||
fmt.Println(final1) | ||
assert.Equal(t, false, final1) | ||
|
||
final2 := s.Eval("TIBCO", "tibco") | ||
fmt.Println(final2) | ||
assert.Equal(t, true, final2) | ||
|
||
} | ||
|
||
func TestExpression(t *testing.T) { | ||
fun, err := expression.NewFunctionExpression(`string.equalsIgnoreCase("TIBCO FLOGO", "TIBCO FLOGO")`).GetFunction() | ||
assert.Nil(t, err) | ||
assert.NotNil(t, fun) | ||
v, err := fun.Eval() | ||
assert.Nil(t, err) | ||
assert.NotNil(t, v) | ||
assert.Equal(t, true, v[0]) | ||
} | ||
|
||
func TestExpressionIgnoreCase(t *testing.T) { | ||
fun, err := expression.NewFunctionExpression(`string.equalsIgnoreCase("TIBCO flogo", "TIBCO FLOGO")`).GetFunction() | ||
assert.Nil(t, err) | ||
assert.NotNil(t, fun) | ||
v, err := fun.Eval() | ||
assert.Nil(t, err) | ||
assert.NotNil(t, v) | ||
assert.Equal(t, true, v[0]) | ||
} |
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