cerberus-core icon indicating copy to clipboard operation
cerberus-core copied to clipboard

Null Values in Cerberus

Open Galand-V opened this issue 5 years ago • 4 comments

Hello,

Currently null values from an SQL datalib are considered as string and returned with this format :

[
{
dividedOpens: "<NULL>",
dividedCloses: "<NULL>",
opens: "<NULL>",
closes: "<NULL>"
}
]

As Json API Standard advise could, you change the format of thoses null values in response ?

[
{
dividedOpens: null,
dividedCloses: null,
opens: null,
closes: "null
}
]

The aim of this issue is to compare null values without any conversion needed

Galand-V avatar Jan 15 '20 10:01 Galand-V

By default in JAVA putting a null string into a JSONObject do not generate any entry on the final JSON Object. Why don't you test the string or text = <NULL> in order to confirm what is null ? In other wors what use case do you try to solve ? I guess a control but which control with which values ?

vertigo17 avatar Jan 15 '20 13:01 vertigo17

I compare information from DB and from an API. Depending on the property, this property can be 'null' or associated to an other value.

The control is 'verifyTextInElement' with a jsonPath that returns me 'null'. The DB control returns me "<NULL>".

In this example, I have to reworked the "<NULL>" with an intermediate property :

getFromGroovy :

def hour = "%property.workingHourSaturday.closes%"; 
hour.replaceAll("<","").replaceAll(">","")

so I can the following result :

Element '$.data[6].attributes.opens' with value 'null' is equal to 'NULL' with case sensitive constraint : ''.

Galand-V avatar Jan 20 '20 10:01 Galand-V

What about adding a parameter in order to defined and tune the value you wnt to use of null SQL values ?

vertigo17 avatar Feb 09 '20 21:02 vertigo17

Yes that is something that could work.

Do you think this change would not be wanted by the majority of Cerberus users ? It seems that comparing elements depending on the type is often used in api testing.

Galand-V avatar Jul 15 '20 15:07 Galand-V