mardi 17 avril 2018

Test if flash attribute is a not-empty string

I'm using MockMvc to test my Controller class. The request should generate a flash attribute with some string content. I want to test if it is so.

I already tried this:

.andExpect( flash().attribute("errorDelete", not(isEmptyOrNullString())) );

which gives this exception:

java.lang.AssertionError: Flash attribute 'errorDelete' 
Expected :org.assertj.core.api.filter.NotFilter@4c65d8e3
Actual   :error.last_user

and this:

.andExpect( flash().attribute("errorDelete", is(not(isEmptyOrNullString()))) );

with this exception:

java.lang.AssertionError: Flash attribute 'errorDelete'
Expected: is <org.assertj.core.api.filter.NotFilter@78288f83>
     but: was "error.last_user"

is(not(empty())) gives the same result.

How to test for an not-empty string in flash attribute?

Aucun commentaire:

Enregistrer un commentaire