Skip to content

Commit

Permalink
fix: ON_GRID_CELL_CLICK event parsing failes when value is null
Browse files Browse the repository at this point in the history
fix #179
  • Loading branch information
hyyan committed Mar 16, 2020
1 parent 99ddcb7 commit a304cd3
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 22 deletions.
6 changes: 3 additions & 3 deletions BBjGridExWidgetClientJsonFactory.bbj
Expand Up @@ -103,9 +103,9 @@ class public BBjGridExWidgetClientJsonFactory
rem */
method public BBjGridExWidgetClientCellModel getCell(JsonObject json!)
cell! = new BBjGridExWidgetClientCellModel()
cell!.setColumn(#getColumn(json!.get("c").getAsString()))
cell!.setRow(#getRow(json!.get("r").getAsJsonObject()))
cell!.setValue(json!.get("v").getAsString())
cell!.setColumn(#getColumn(json!.get("c").getAsString()),err=*next)
cell!.setRow(#getRow(json!.get("r").getAsJsonObject()),err=*next)
cell!.setValue(json!.get("v").getAsString(),err=*next)
methodret cell!
methodend
rem /**
Expand Down
Expand Up @@ -17,18 +17,18 @@ use com.google.gson.JsonParser
class public BBjGridExWidgetClientJsonFactoryTest

field private BBjGridExWidgetClientJsonFactory Instance!
field private BBjString FilterFixturesString$
field private BBjString ModelsFixturesString$

method private JsonObject getFilterModelsFixture()
method private JsonObject getModelsFixture()
parser! = new JsonParser()
methodret parser!.parse(#FilterFixturesString$).getAsJsonObject()
methodret parser!.parse(#ModelsFixturesString$).getAsJsonObject()
methodend

rem @BeforeClass
method public void beforeClass()
ch=unt
open (ch) BBjAPI().getFileSystem().resolvePath("BBjGridExWidget/test/Fixtures/FilterModels.json")
read record (ch,siz=5512000)#FilterFixturesString$
open (ch) BBjAPI().getFileSystem().resolvePath("BBjGridExWidget/test/Fixtures/Models.json")
read record (ch,siz=5512000)#ModelsFixturesString$
close (ch)

methodend
Expand All @@ -46,7 +46,7 @@ class public BBjGridExWidgetClientJsonFactoryTest
rem @Test
method public void testGetFilterConditionCanCreateFilterNumberModel()
declare auto JsonObject fixture!
fixture! = #getFilterModelsFixture().get("number-single")
fixture! = #getModelsFixture().get("filter-number-single")
column! = "foo"

rem complete
Expand Down Expand Up @@ -76,7 +76,7 @@ class public BBjGridExWidgetClientJsonFactoryTest
rem @Test
method public void testGetFilterConditionCanCreateFilterDateTimeModel()
declare auto JsonObject fixture!
fixture! = #getFilterModelsFixture().get("datetime-single")
fixture! = #getModelsFixture().get("filter-datetime-single")
column! = "foo"

rem complete
Expand Down Expand Up @@ -106,7 +106,7 @@ class public BBjGridExWidgetClientJsonFactoryTest
rem @Test
method public void testGetFilterConditionCanCreateFilterTextModel()
declare auto JsonObject fixture!
fixture! = #getFilterModelsFixture().get("text-single")
fixture! = #getModelsFixture().get("filter-text-single")
column! = "foo"

rem complete
Expand All @@ -128,7 +128,7 @@ class public BBjGridExWidgetClientJsonFactoryTest
rem @Test
method public void testGetFilterConditionCanCreateFilterBooleanModel()
declare auto JsonObject fixture!
fixture! = #getFilterModelsFixture().get("boolean-single")
fixture! = #getModelsFixture().get("filter-boolean-single")
column! = "foo"

rem complete
Expand All @@ -142,7 +142,7 @@ class public BBjGridExWidgetClientJsonFactoryTest
rem @Test
method public void testGetFilterConditionCanCreateFilterSetFilterModel()
declare auto JsonObject fixture!
fixture! = #getFilterModelsFixture().get("set")
fixture! = #getModelsFixture().get("filter-set")
column! = "foo"

rem complete
Expand All @@ -156,7 +156,7 @@ class public BBjGridExWidgetClientJsonFactoryTest
rem @Test
method public void testGetFilterCanCreateCombinedFilteModel()
declare auto JsonObject fixture!
fixture! = #getFilterModelsFixture().get("number-combined")
fixture! = #getModelsFixture().get("filter-number-combined")
column! = "foo"

fixtureClone! = fixture!.deepCopy()
Expand Down Expand Up @@ -200,7 +200,46 @@ class public BBjGridExWidgetClientJsonFactoryTest
model! = cast(BBjGridExWidgetClientFilterNumberModel,model!,err=*next); isNumberModel! = 1
Assert.Equals(isNumberModel!,1)
methodend


rem @Test
method public void testGetCell()
declare auto JsonObject fixture!
fixture! = #getModelsFixture().get("event-cell")

fixtureClone! = fixture!.deepCopy()
model! = #Instance!.getCell(fixtureClone!.getAsJsonObject())

Assert.Equals(model!.toString().endsWith("BBjGridExWidgetClientCellModel"), BBjAPI.TRUE)
Assert.Equals(model!.getRow().getId(),"4131adda-c690-36ef-85c9-76ecf1612bdb")
Assert.Equals(model!.getColumn().getName(),"test")
Assert.Equals(model!.getValue(),"newValue")

fixtureClone! = fixture!.deepCopy()
fixtureClone!.remove("r"); rem remove row
model! = #Instance!.getCell(fixtureClone!.getAsJsonObject())

Assert.Equals(model!.toString().endsWith("BBjGridExWidgetClientCellModel"), BBjAPI.TRUE)
Assert.IsNull(model!.getRow())
Assert.Equals(model!.getColumn().getName(),"test")
Assert.Equals(model!.getValue(),"newValue")

fixtureClone! = fixture!.deepCopy()
fixtureClone!.remove("c"); rem remove column
model! = #Instance!.getCell(fixtureClone!.getAsJsonObject())
Assert.Equals(model!.toString().endsWith("BBjGridExWidgetClientCellModel"), BBjAPI.TRUE)
Assert.Equals(model!.getRow().getId(),"4131adda-c690-36ef-85c9-76ecf1612bdb")
Assert.IsNull(model!.getColumn())
Assert.Equals(model!.getValue(),"newValue")

fixtureClone! = fixture!.deepCopy()
fixtureClone!.remove("v"); rem remove value
model! = #Instance!.getCell(fixtureClone!.getAsJsonObject())
Assert.Equals(model!.toString().endsWith("BBjGridExWidgetClientCellModel"), BBjAPI.TRUE)
Assert.Equals(model!.getRow().getId(),"4131adda-c690-36ef-85c9-76ecf1612bdb")
Assert.Equals(model!.getColumn().getName(),"test")
Assert.IsNull(model!.getValue())
methodend

rem @After
method public void tearDown()
#Instance! = null()
Expand Down
29 changes: 22 additions & 7 deletions test/Fixtures/FilterModels.json → test/Fixtures/Models.json
@@ -1,11 +1,11 @@
{
"number-single": {
"filter-number-single": {
"filterType": "number",
"type": "equals",
"filter": 1,
"filterTo": 10
},
"number-combined": {
"filter-number-combined": {
"filterType": "number",
"operator": "OR",
"condition1": {
Expand All @@ -21,23 +21,38 @@
"filterTo": 10
}
},
"datetime-single": {
"filter-datetime-single": {
"filterType": "datetime",
"type": "equals",
"filter": "2020-01-01",
"filterTo": "2020-01-01"
},
"text-single": {
"filter-text-single": {
"filterType": "text",
"type": "equals",
"filter": "sometext"
},
"boolean-single": {
"filter-boolean-single": {
"filterType": "boolean",
"value": "true"
},
"set": {
"filter-set": {
"filterType": "set",
"values": [1,2,3]
"values": [
1,
2,
3
]
},
"event-cell": {
"c": "test",
"r": {
"i": "4131adda-c690-36ef-85c9-76ecf1612bdb",
"x": 3,
"p": "",
"c": 3,
"s": true
},
"v": "newValue"
}
}

0 comments on commit a304cd3

Please sign in to comment.