Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davdarras committed Mar 29, 2024
1 parent 57f32d3 commit f913c76
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ void testSurveyUnitUpdateDataStateData01() {
}

@Test
@DisplayName("When updating collected data, verify habilitation")
@DisplayName("When updating collected data, then verify habilitation")
void testSurveyUnitUpdateColllectedData01() {
String surveyUnitId = "11";
ObjectNode data = JsonNodeFactory.instance.objectNode();
StateDataInput stateData = new StateDataInput(StateDataTypeInput.INIT, 0L, "2.3");
SurveyUnitDataStateDataUpdateInput su = new SurveyUnitDataStateDataUpdateInput(data, stateData);
perfDataController.updateSurveyUnitDataStateDataById(surveyUnitId, su);
ObjectNode collectedData = JsonNodeFactory.instance.objectNode();
perfDataController.updateCollectedData(collectedData, surveyUnitId);
assertThat(pilotageFakeComponent.isChecked()).isTrue();
assertThat(dataFakeService.isCheckUpdateCollectedData()).isTrue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,17 @@ void on_update_data_when_anonymous_user_return_401() throws Exception {
@Test
@Sql(value = ScriptConstants.REINIT_SQL_SCRIPT, executionPhase = AFTER_TEST_METHOD)
void on_update_collected_data_data_is_updated() throws Exception {
String surveyUnitId = "12";
String surveyUnitId = "11";
String collectedDataJson = """
{
"hey": "ho",
"obj": {"plip": "plop"},
"numb": 2
"numb": 2,
"READY": {
"EDITED": true,
"COLLECTED":false
},
"COMMENT": null
}""";
MvcResult result = mockMvc.perform(get("/api/survey-unit/" + surveyUnitId + "/data")
.accept(MediaType.APPLICATION_JSON)
Expand Down Expand Up @@ -188,7 +193,32 @@ void on_update_collected_data_data_is_updated() throws Exception {
.andReturn();

content = result.getResponse().getContentAsString();
String expectedResult = "{}";
String expectedResult = """
{
"EXTERNAL":{
"LAST_BROADCAST":"12/07/1998"
},
"COLLECTED":{
"hey":"ho",
"obj":{
"plip":"plop"
},
"numb":2,
"READY":{
"EDITED":true,
"COLLECTED":false
},
"COMMENT": null,
"PRODUCER":{
"EDITED":null,
"FORCED":null,
"INPUTED":null,
"PREVIOUS":null,
"COLLECTED":"Matt Groening"
}
}
}
""";
JSONAssert.assertEquals(expectedResult, content, JSONCompareMode.STRICT);
}

Expand Down

0 comments on commit f913c76

Please sign in to comment.