-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add unit to double check when we verify if a parent object is a…
…lready published
- Loading branch information
1 parent
e216b1e
commit 406ca97
Showing
8 changed files
with
160 additions
and
45 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
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
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
41 changes: 41 additions & 0 deletions
41
...t/java/fr/insee/rmes/bauhaus_services/operations/operations/OperationPublicationTest.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,41 @@ | ||
package fr.insee.rmes.bauhaus_services.operations.operations; | ||
|
||
import fr.insee.rmes.bauhaus_services.Constants; | ||
import fr.insee.rmes.bauhaus_services.operations.ParentUtils; | ||
import fr.insee.rmes.exceptions.RmesBadRequestException; | ||
import fr.insee.rmes.exceptions.RmesException; | ||
import fr.insee.rmes.model.ValidationStatus; | ||
import org.json.JSONObject; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class OperationPublicationTest { | ||
|
||
@InjectMocks | ||
OperationPublication operationPublication; | ||
|
||
@Mock | ||
ParentUtils ownerUtils; | ||
|
||
@Test | ||
void shouldThrowExceptionIfParentSeriesIsUnpublished() throws RmesException { | ||
JSONObject operation = new JSONObject(); | ||
operation.put(Constants.ID, "1"); | ||
JSONObject series = new JSONObject(); | ||
series.put("id", "2"); | ||
operation.put("series", series); | ||
|
||
when(ownerUtils.getValidationStatus("2")).thenReturn(ValidationStatus.UNPUBLISHED.toString()); | ||
assertThrows( | ||
RmesBadRequestException.class, | ||
() -> operationPublication.publishOperation("1", operation) | ||
); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/test/java/fr/insee/rmes/bauhaus_services/operations/series/SeriesPublicationTest.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,40 @@ | ||
package fr.insee.rmes.bauhaus_services.operations.series; | ||
|
||
import fr.insee.rmes.bauhaus_services.Constants; | ||
import fr.insee.rmes.bauhaus_services.operations.ParentUtils; | ||
import fr.insee.rmes.exceptions.RmesBadRequestException; | ||
import fr.insee.rmes.exceptions.RmesException; | ||
import fr.insee.rmes.model.ValidationStatus; | ||
import org.json.JSONObject; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class SeriesPublicationTest { | ||
@InjectMocks | ||
SeriesPublication seriesPublication; | ||
|
||
@Mock | ||
ParentUtils ownerUtils; | ||
|
||
@Test | ||
void shouldThrowExceptionIfParentFamilyIsUnpublished() throws RmesException { | ||
JSONObject series = new JSONObject(); | ||
series.put(Constants.ID, "1"); | ||
JSONObject family = new JSONObject(); | ||
family.put("id", "2"); | ||
series.put("family", family); | ||
|
||
when(ownerUtils.getValidationStatus("2")).thenReturn(ValidationStatus.UNPUBLISHED.toString()); | ||
assertThrows( | ||
RmesBadRequestException.class, | ||
() -> seriesPublication.publishSeries("1", series) | ||
); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/test/java/fr/insee/rmes/bauhaus_services/rdf_utils/PublicationUtilsTest.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,24 @@ | ||
package fr.insee.rmes.bauhaus_services.rdf_utils; | ||
|
||
import fr.insee.rmes.bauhaus_services.Constants; | ||
import fr.insee.rmes.model.ValidationStatus; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class PublicationUtilsTest { | ||
@Test | ||
void testIsUnpublished() { | ||
String unpublishedStatus = ValidationStatus.UNPUBLISHED.getValue(); | ||
assertTrue(PublicationUtils.isUnublished(unpublishedStatus)); | ||
|
||
String undefinedStatus = Constants.UNDEFINED; | ||
assertTrue(PublicationUtils.isUnublished(undefinedStatus)); | ||
|
||
String otherStatus = "OTHER_STATUS"; | ||
assertFalse(PublicationUtils.isUnublished(otherStatus)); | ||
|
||
assertFalse(PublicationUtils.isUnublished(null)); | ||
} | ||
} |