This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
forked from MORE-Platform/more-studymanager-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#mpa-227 changing lime survey id for running study is now forbidden
- Loading branch information
Thomas Kurz
committed
Mar 25, 2024
1 parent
790286f
commit 0f09ce4
Showing
5 changed files
with
87 additions
and
7 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
37 changes: 37 additions & 0 deletions
37
...va/io/redlink/more/studymanager/component/observation/lime/LimeSurveyObservationTest.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,37 @@ | ||
package io.redlink.more.studymanager.component.observation.lime; | ||
|
||
import io.redlink.more.studymanager.core.properties.ObservationProperties; | ||
import io.redlink.more.studymanager.core.sdk.MoreObservationSDK; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Optional; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class LimeSurveyObservationTest { | ||
@Test | ||
public void testLimeSurveyIdValidation() { | ||
MoreObservationSDK sdk = mock(MoreObservationSDK.class); | ||
ObservationProperties properties = mock(ObservationProperties.class); | ||
|
||
when(sdk.getValue(anyString(), any())) | ||
.thenReturn(Optional.empty(), Optional.of("equals"), Optional.of("other")); | ||
when(properties.getString(anyString())).thenReturn("valid", "equals", "different"); | ||
|
||
LimeSurveyObservation o = new LimeSurveyObservation(sdk, properties, null); | ||
Assertions.assertEquals("valid", o.checkAndGetSurveyId()); | ||
Assertions.assertEquals("equals", o.checkAndGetSurveyId()); | ||
boolean expectedError = false; | ||
try { | ||
o.checkAndGetSurveyId(); | ||
} catch (RuntimeException e) { | ||
expectedError = true; | ||
} | ||
|
||
Assertions.assertTrue(expectedError); | ||
} | ||
} |
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