-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed error 400 when invalid json request + add test
- Loading branch information
1 parent
9bdb6fa
commit 93585c7
Showing
3 changed files
with
49 additions
and
14 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
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
26 changes: 26 additions & 0 deletions
26
src/test/java/fr/insee/genesis/domain/service/rawdata/LunaticJsonRawDataServiceTest.java
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,26 @@ | ||
package fr.insee.genesis.domain.service.rawdata; | ||
|
||
import com.fasterxml.jackson.core.JsonParseException; | ||
import fr.insee.genesis.domain.model.surveyunit.Mode; | ||
import fr.insee.genesis.stubs.LunaticJsonPersistanceStub; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class LunaticJsonRawDataServiceTest { | ||
LunaticJsonPersistanceStub lunaticJsonPersistanceStub = new LunaticJsonPersistanceStub(); | ||
LunaticJsonRawDataService lunaticJsonRawDataService = new LunaticJsonRawDataService(lunaticJsonPersistanceStub); | ||
|
||
@Test | ||
void saveDataTest_Invalid(){ | ||
lunaticJsonPersistanceStub.getMongoStub().clear(); | ||
String campaignId = "SAMPLETEST-PARADATA-v1"; | ||
|
||
Assertions.assertThatThrownBy(() -> { | ||
lunaticJsonRawDataService.saveData( | ||
campaignId | ||
,"{\"testdata\": \"ERROR" | ||
, Mode.WEB | ||
); | ||
}).isInstanceOf(JsonParseException.class); | ||
} | ||
} |