Commit 9738dead authored by Baptiste Toulemonde's avatar Baptiste Toulemonde
Browse files

feat tu

parent 1810380f
......@@ -89,11 +89,11 @@ public class PuaPastisValidator {
private JSONObject getProfileJsonExpected(boolean standalone) {
if (profileJsonExpected == null) {
InputStream inputStream;
if(standalone)
inputStream = getClass().getClassLoader().getResourceAsStream("pua_validation/valid_pua.json");
if (standalone)
inputStream = getClass().getClassLoader().getResourceAsStream("pua_validation/valid_pua.json");
else{
inputStream = getClass().getClassLoader().getResourceAsStream("pua_validation/valid_pua_vitam.json");
else {
inputStream = getClass().getClassLoader().getResourceAsStream("pua_validation/valid_pua_vitam.json");
}
assert inputStream != null;
JSONTokener tokener = new JSONTokener(new InputStreamReader(inputStream));
......@@ -138,20 +138,20 @@ public class PuaPastisValidator {
// Compare list of field at the root level
if (!standalone) {
Set<String> actualFieldList = pua.keySet().stream().collect(toSet());
if(!actualFieldList.contains("name") && !actualFieldList.contains("controlSchema")){
if (!actualFieldList.contains("name") && !actualFieldList.contains("controlSchema")) {
throw new AssertionError("Notice not contains the expected keys 'name' and 'controlSchema'");
}
}
// Next tests are controlling the ControlSchema
String controlSchemaString = pua.getString(CONTROLSCHEMA);
JSONObject controlSchemaActual = new JSONObject(controlSchemaString);
controlSchemaString = profileJson.getString(CONTROLSCHEMA);
JSONObject controlSchemaExpected = new JSONObject(controlSchemaString);
LOGGER.error(controlSchemaActual.toString() + " control schema actuelle");
// Next tests are controlling the ControlSchema
String controlSchemaString = pua.getString(CONTROLSCHEMA);
JSONObject controlSchemaActual = new JSONObject(controlSchemaString);
controlSchemaString = profileJson.getString(CONTROLSCHEMA);
JSONObject controlSchemaExpected = new JSONObject(controlSchemaString);
LOGGER.error(controlSchemaActual.toString() + " control schema actuelle");
LOGGER.error(controlSchemaExpected.toString() + " control schema Expected");
if(standalone) {
if (standalone) {
// Checking that the whole structure is respected. Doesn't care that the pua contains extended fields.
//JSONAssert.assertEquals(controlSchemaExpected, controlSchemaActual, JSONCompareMode.LENIENT);
......@@ -159,37 +159,41 @@ public class PuaPastisValidator {
// JSONAssert.assertEquals(controlSchemaExpected.getJSONObject(DEFINITIONS),
// controlSchemaActual.getJSONObject(DEFINITIONS), JSONCompareMode.STRICT);
// Checking that additionalProperties is present and is boolean
if (controlSchemaActual.has("additionalProperties") &&
!(controlSchemaActual.get("additionalProperties") instanceof Boolean)) {
throw new AssertionError("PUA additionalProperties field does not contains a boolean value");
}
// Checking that #management object is present and at the correct position
if (controlSchemaActual.has("patternProperties")) {
JSONObject patternProperties = controlSchemaActual.getJSONObject("patternProperties");
if (patternProperties.has(MANAGEMENTCONTROL)) {
JSONAssert.assertEquals(new JSONObject(), patternProperties.getJSONObject(MANAGEMENTCONTROL),
JSONCompareMode.STRICT);
// Check that #management is not in both header and 'properties' object
JSONObject properties = controlSchemaActual.getJSONObject(PROPERTIES);
if (properties.has(MANAGEMENTCONTROL)) {
throw new AssertionError("Can't have both '#management' key in header and in 'properties' object");
// Checking that additionalProperties is present and is boolean
if (controlSchemaActual.has("additionalProperties") &&
!(controlSchemaActual.get("additionalProperties") instanceof Boolean)) {
throw new AssertionError("PUA additionalProperties field does not contains a boolean value");
}
// Checking that #management object is present and at the correct position
if (controlSchemaActual.has("patternProperties")) {
JSONObject patternProperties = controlSchemaActual.getJSONObject("patternProperties");
if (patternProperties.has(MANAGEMENTCONTROL)) {
JSONAssert.assertEquals(new JSONObject(), patternProperties.getJSONObject(MANAGEMENTCONTROL),
JSONCompareMode.STRICT);
// Check that #management is not in both header and 'properties' object
JSONObject properties = controlSchemaActual.getJSONObject(PROPERTIES);
if (properties.has(MANAGEMENTCONTROL)) {
throw new AssertionError("Can't have both '#management' key in header and in 'properties' object");
}
}
} else {
if (controlSchemaActual.has(PROPERTIES)) {
JSONObject properties = controlSchemaActual.getJSONObject(PROPERTIES);
if (!properties.has(MANAGEMENTCONTROL)) {
throw new AssertionError("Missing '#management' key in 'properties' object");
}
} else {
throw new AssertionError("Missing 'properties' key in controlShema");
}
// #HAVEFUN
}
} else {
JSONObject properties = controlSchemaActual.getJSONObject(PROPERTIES);
if (!properties.has(MANAGEMENTCONTROL)) {
throw new AssertionError("Missing '#management' key in 'properties' object");
if (!controlSchemaActual.has(SCHEMA)) {
throw new AssertionError("Missing '$schema' key in controlSchema' object");
}
// #HAVEFUN
}
}
else{
if (!controlSchemaActual.has(SCHEMA)) {
throw new AssertionError("Missing '$schema' key in controlSchema' object");
}
}
}
public JSONObject getDefinitionsFromExpectedProfile() {
......@@ -228,11 +232,11 @@ public class PuaPastisValidator {
String sedaName = sedaElement.getName();
String sedaCardinality = sedaElement.getCardinality();
if(sedaName.equals("algorithm")){
if (sedaName.equals("algorithm")) {
return "string";
}
if(sedaName.equals("Title") || sedaName.equals("Description")) {
if (sedaName.equals("Title") || sedaName.equals("Description")) {
if (element.getCardinality().equals("1")) {
return "string";
} else {
......@@ -251,7 +255,7 @@ public class PuaPastisValidator {
if (sedaType.equals("boolean") && (sedaCardinality.equals("0-1") || sedaCardinality.equals("1"))) {
return "boolean";
}
if (sedaType.equals("integer")&& (sedaCardinality.equals("0-1") || sedaCardinality.equals("1"))) {
if (sedaType.equals("integer") && (sedaCardinality.equals("0-1") || sedaCardinality.equals("1"))) {
return "integer";
}
if (sedaCardinality.equals("1-N") || sedaCardinality.equals("0-N")) {
......@@ -303,7 +307,7 @@ public class PuaPastisValidator {
"ReuseRule", "ClassificationRule");
for (ElementProperties el : elementsFromTree) {
setMetadataName(el);
setMetadataName(el);
try {
if (el.getName().equals(MANAGEMENT)) {
JSONObject management = getJSONFromManagement(el);
......@@ -368,7 +372,7 @@ public class PuaPastisValidator {
* @throws IOException
*/
private void retrieveAccumalatedJsonManagaementProperties(ElementProperties element, List<String> rulesMetadata,
List<String> childrenToEncapsulate, List<String> rulesFound, JSONObject pua) throws IOException {
List<String> childrenToEncapsulate, List<String> rulesFound, JSONObject pua) throws IOException {
for (ElementProperties childElement : element.getChildren()) {
JSONObject childrenOfRule = sortedJSON();
JSONObject grandChildrenOfRule = sortedJSON();
......@@ -437,7 +441,7 @@ public class PuaPastisValidator {
* @return
*/
private boolean checkSpecialCases(List<String> rulesMetadata, List<String> rulesFound,
ElementProperties childElement, SedaNode sedaElement) {
ElementProperties childElement, SedaNode sedaElement) {
if (!rulesMetadata.contains(childElement.getName()) || sedaElement == null) {
return true;
}
......@@ -455,7 +459,7 @@ public class PuaPastisValidator {
* @param ruleTypeMetadata
*/
private void putRequiredNonSpecialChildren(ElementProperties childElement, List<String> requiredNonSpecialChildren,
JSONObject ruleTypeMetadata) {
JSONObject ruleTypeMetadata) {
if (!requiredNonSpecialChildren.isEmpty()) {
ruleTypeMetadata.getJSONObject(childElement.getName())
.put(REQUIRED, requiredNonSpecialChildren);
......@@ -471,7 +475,7 @@ public class PuaPastisValidator {
* @param requiredChildren
*/
private void putChildrenIntoRules(JSONObject childrenOfRule, JSONObject grandChildrenOfRule,
JSONObject propertiesRules, List<String> requiredChildren) {
JSONObject propertiesRules, List<String> requiredChildren) {
if (!grandChildrenOfRule.isEmpty()) {
JSONObject propretyOfItems = new JSONObject().put(ADDITIONAL_PROPERTIES, false);
propretyOfItems.put(PROPERTIES, grandChildrenOfRule);
......@@ -493,8 +497,8 @@ public class PuaPastisValidator {
* @throws JsonProcessingException
*/
private void childrenContainsGrandChildName(JSONObject grandChildrenOfRule,
PuaMetadataDetails ruleTypeMetadataDetails, List<String> requiredChildren, ElementProperties grandChild,
SedaNode node) throws JsonProcessingException {
PuaMetadataDetails ruleTypeMetadataDetails, List<String> requiredChildren, ElementProperties grandChild,
SedaNode node) throws JsonProcessingException {
PuaMetadataDetails childOfRuleDetails = new PuaMetadataDetails();
getMetaDataFromSeda(grandChild, childOfRuleDetails, node);
if (grandChild.getCardinality().equals("1"))
......@@ -511,7 +515,7 @@ public class PuaPastisValidator {
* Retrieve the accumulated JSONArray properties from pua
*
* @param pua is JSONObjet that contains Management section of PUA
* Convert it into a JSONObject and put it into a #mangagement key
* Convert it into a JSONObject and put it into a #mangagement key
*/
public JSONObject retrieveAccumulatedJsonManagementProperties(JSONObject pua) {
......@@ -555,7 +559,7 @@ public class PuaPastisValidator {
.getChildren().stream().filter(childName -> childName.getName().equals(elementName)).findAny().orElse(null);
} else {
result = sedaTree.flattened()
.filter(e -> e.getName().equals(elementName) ).findAny().orElse(null);
.filter(e -> e.getName().equals(elementName)).findAny().orElse(null);
}
return result;
}
......
......@@ -52,7 +52,6 @@ public class PuaPastisValidatorNOKTest {
@Parameters
public static Collection<String> data() {
return Arrays.asList(new String[] {
"pua/pua_NOK_missing_definitions.json",
"pua/pua_NOK_missing_management.json",
"pua/pua_NOK_missing_properties.json",
"pua/pua_NOK_both_management_present.json"
......
......@@ -165,7 +165,7 @@ public class PastisService {
try {
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(notice);
} catch (JsonProcessingException e) {
throw new TechnicalException("Problems durint conversion objectMapper to string", e);
throw new TechnicalException("Problems during conversion objectMapper to string", e);
}
}
......
......@@ -8,7 +8,7 @@
"lastUpdate": "2020-11-26T14:08:20.987",
"activationDate": "2016-12-10T00:00:00.000",
"deactivationDate": "2016-12-10T00:00:00.000",
"controlSchema": "{\"$schema\":\"http://json-schema.org/draft-04/schema\",\"type\":\"object\",\"additionalProperties\":false,\"patternProperties\":{\"#management\":{}},\"required\":[\"ArchiveUnitProfile\",\"DescriptionLevel\",\"Title_\",\"#management\"],\"definitions\":{\"pattern-simple-date\":{\"type\":\"string\",\"pattern\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}\"},\"pattern-date\":{\"type\":\"string\",\"pattern\":\"^([0-8][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))$\"}},\"properties\":{{\"#management\":{\"additionalProperties\": false},\"ArchiveUnitProfile\":{\"type\":\"string\",\"description\":\"Identifiant du PUA : cardinalité 1\"},\"DescriptionLevel\":{\"type\":\"string\",\"description\":\"Niveau de description : cardinalité 1\"},\"Title_\":{\"type\":\"object\",\"description\":\"Titre de la ressource : cardinalité 1-N\"}}}",
"controlSchema": "{\"$schema\":\"http://json-schema.org/draft-04/schema\",\"type\":\"object\",\"additionalProperties\":false,\"patternProperties\":{\"#management\":{}},\"required\":[\"ArchiveUnitProfile\",\"DescriptionLevel\",\"Title_\",\"#management\"],\"definitions\":{\"pattern-simple-date\":{\"type\":\"string\",\"pattern\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}\"},\"pattern-date\":{\"type\":\"string\",\"pattern\":\"^([0-8][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))$\"}},\"properties\":{\"#management\":{\"additionalProperties\": false},\"ArchiveUnitProfile\":{\"type\":\"string\",\"description\":\"Identifiant du PUA : cardinalité 1\"},\"DescriptionLevel\":{\"type\":\"string\",\"description\":\"Niveau de description : cardinalité 1\"},\"Title_\":{\"type\":\"object\",\"description\":\"Titre de la ressource : cardinalité 1-N\"}}}",
"tenant": 8,
"version": 1,
"fields": [
......
package fr.gouv.vitamui.pastis.server.rest;
import fr.gouv.vitamui.commons.api.domain.IdDto;
import fr.gouv.vitamui.commons.api.domain.ServicesData;
import fr.gouv.vitamui.commons.api.logger.VitamUILogger;
import fr.gouv.vitamui.commons.rest.client.ExternalHttpContext;
import fr.gouv.vitamui.commons.security.client.dto.AuthUserDto;
import fr.gouv.vitamui.commons.test.rest.AbstractMockMvcCrudControllerTest;
import fr.gouv.vitamui.commons.test.rest.AbstractRestControllerMockMvcTest;
import fr.gouv.vitamui.iam.security.authentication.ExternalAuthentication;
import fr.gouv.vitamui.iam.security.provider.ExternalApiAuthenticationProvider;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.core.Authentication;
import java.util.List;
public abstract class ControllerTest extends AbstractRestControllerMockMvcTest {
@MockBean
private ExternalApiAuthenticationProvider apiAuthenticationProvider;
@Override
protected Authentication buildUserAuthenticated() {
final Authentication authentication = new ExternalAuthentication(buildPrincipal(), buildCredentials(),null,buildUserRoles());
return authentication;
}
protected AuthUserDto buildPrincipal() {
final AuthUserDto user = new AuthUserDto();
user.setFirstname("test");
return user;
}
protected ExternalHttpContext buildCredentials() {
return null;
}
protected List<String> buildUserRoles() {
return ServicesData.getServicesByName(getServices());
}
protected abstract String[] getServices();
}
package fr.gouv.vitamui.pastis.server.rest;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import fr.gouv.vitamui.commons.api.domain.IdDto;
import fr.gouv.vitamui.commons.api.domain.ServicesData;
import fr.gouv.vitamui.commons.api.identity.ServerIdentityConfiguration;
import fr.gouv.vitamui.commons.api.logger.VitamUILogger;
import fr.gouv.vitamui.commons.api.logger.VitamUILoggerFactory;
import fr.gouv.vitamui.commons.rest.RestExceptionHandler;
import fr.gouv.vitamui.commons.test.rest.AbstractRestControllerMockMvcTest;
import fr.gouv.vitamui.iam.security.provider.ExternalApiAuthenticationProvider;
import fr.gouv.vitamui.pastis.common.dto.ElementProperties;
import fr.gouv.vitamui.pastis.common.dto.profiles.Notice;
import fr.gouv.vitamui.pastis.common.dto.profiles.ProfileNotice;
import fr.gouv.vitamui.pastis.common.dto.profiles.ProfileResponse;
import fr.gouv.vitamui.pastis.common.exception.TechnicalException;
import fr.gouv.vitamui.pastis.common.rest.RestApi;
import fr.gouv.vitamui.pastis.common.service.JsonFromPUA;
import fr.gouv.vitamui.pastis.common.service.PuaPastisValidator;
import fr.gouv.vitamui.pastis.server.ApiPastisServerApplication;
import fr.gouv.vitamui.pastis.server.security.WebSecurityConfig;
import fr.gouv.vitamui.pastis.server.service.PastisService;
import lombok.SneakyThrows;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import org.springframework.security.core.Authentication;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.util.UriComponentsBuilder;
import java.io.IOException;
import java.io.InputStream;
import java.security.NoSuchAlgorithmException;
import static org.mockito.ArgumentMatchers.any;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(SpringRunner.class)
@WebMvcTest(controllers = PastisController.class)
@Import(value = { WebSecurityConfig.class, ServerIdentityConfiguration.class, RestExceptionHandler.class })
public class PastisControllerTest extends ControllerTest {
private static final VitamUILogger LOGGER = VitamUILoggerFactory.getInstance(PastisControllerTest.class);
@MockBean
private PastisService service;
private PastisController controller;
@Before
public void setUp() throws Exception {
controller = new PastisController(service);
}
@Test
public void testGetArchiveProfile_should_return_ok() throws IOException, TechnicalException {
UriComponentsBuilder uriBuilder = getUriBuilder("/archiveprofile");
Mockito.when(service.getArchiveProfile(any(ElementProperties.class))).thenReturn("");
InputStream jsonInputStream = getClass().getClassLoader().getResourceAsStream("rng/ProfileJson.json");
ObjectMapper objectMapper = new ObjectMapper();
ElementProperties dto = objectMapper.readValue(jsonInputStream, ElementProperties.class);
super.performPost(uriBuilder, asJsonString(dto), status().isOk());
}
@Test
public void testCreate() throws TechnicalException, NoSuchAlgorithmException {
Mockito.when(service.createProfile(any(String.class), any(Boolean.class))).thenReturn(new ProfileResponse());
super.performGet("/profile", ImmutableMap.of("type", "PUA"), status().isOk());
}
@Override
protected String getRessourcePrefix() {
return RestApi.PASTIS;
}
@Override
protected String[] getServices() {
return new String[] {
ServicesData.ROLE_GET_ARCHIVE_PROFILES,
ServicesData.ROLE_GET_ARCHIVE_PROFILES_UNIT,
ServicesData.ROLE_UPDATE_ARCHIVE_PROFILES,
ServicesData.ROLE_UPDATE_ARCHIVE_PROFILES_UNIT,
ServicesData.ROLE_CREATE_ARCHIVE_PROFILES,
ServicesData.ROLE_CREATE_ARCHIVE_PROFILES_UNIT,
ServicesData.ROLE_GET_PROFILES,
ServicesData.ROLE_UPDATE_PROFILES,
ServicesData.ROLE_CREATE_PROFILES,
ServicesData.ROLE_GET_PASTIS,
ServicesData.ROLE_DELETE_PASTIS,
};
}
}
......@@ -3,6 +3,7 @@ package fr.gouv.vitamui.commons.test.rest;
import static org.junit.Assert.fail;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
......@@ -34,7 +35,7 @@ public abstract class AbstractMockMvcCrudControllerTest<T extends IdDto> extends
* @return ResultActions
*/
public ResultActions testCreateEntity(final ResultMatcher matcher) {
return testCreateEntity(getHeaders());
return testCreateEntity(matcher, getHeaders());
}
......
......@@ -66,7 +66,7 @@ public abstract class AbstractRestControllerMockMvcTest extends AbstractServerId
* @param Object
* @return
*/
protected static String asJsonString(final Object Object) {
public static String asJsonString(final Object Object) {
try {
final ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
......
{
"name": "pastis-standalone",
"name": "vitamui-ui",
"version": "5.4.0-SNAPSHOT",
"license": "MIT",
"pki": {
"path": "../../dev-deployment/environments/certs/server/hosts/localhost",
"asset": "reverse"
},
"scripts": {
"ng": "ng",
"ng-high-memory": "node --max_old_space_size=4000 ./node_modules/@angular/cli/bin/ng",
"ng-high-memory": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng",
"start": "ng serve --proxy-config proxy.conf.json --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt",
"start:en": "ng serve --proxy-config proxy.conf.json --configuration=en --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt",
"start:demo": "ng serve demo --proxy-config proxy.conf.json --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt",
"start:portal": "ng serve portal --proxy-config proxy.conf.json --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt",
"start:starter-kit": "ng serve --proxy-config proxy.conf.json starter-kit --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt",
"start:starter-kit-mocked-server": "ng serve --port 5000 --proxy-config proxy-mock.conf.json starter-kit",
"json-server": "json-server --watch projects/starter-kit/mock-api/_db.js --config projects/starter-kit/mock-api/config.json --routes projects/starter-kit/mock-api/routes.json ",
"mock-starter-kit": "concurrently 'npm run json-server' 'npm run start:starter-kit-mocked-server'",
"start:identity": "ng serve identity --proxy-config proxy.conf.json --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt",
"start:pastis": "ng serve pastis --proxy-config proxy.conf.json --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt",
"build": "ng build --configuration=standalone --i18n-locale fr --build-optimizer=false --optimization=false",
"start:referential": "ng serve referential --proxy-config proxy.conf.json --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt",
"start:ingest": "ng serve ingest --proxy-config proxy.conf.json --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt",
"start:archive-search": "ng serve archive-search --proxy-config proxy.conf.json --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt",
"build": "ng build --prod --i18n-locale fr --build-optimizer=false --optimization=false",
"postinstall": "ngcc",
"build:prod": "export NODE_OPTIONS=--max_old_space_size=4096; ng build --prod --output-path ../../../target/www",
"build:prod": "export NODE_OPTIONS=--max_old_space_size=8192; ng build --prod --output-path ../../../target/www",
"build:dev": "ng build --prod --i18n-locale fr --build-optimizer=false --optimization=false",
"build:fr": "ng build --prod --i18n-locale fr --output-path ../../../target/www/fr",
"build:en": "ng build --prod --i18n-file src/locale/messages.en.xlf --i18n-format xlf --i18n-locale en --output-path ../../../target/www/en",
"build:all": "npm run build:fr && npm run build:en",
"build:demo": "ng build demo --prod --i18n-locale fr",
"build:portal": "export NODE_OPTIONS=--max_old_space_size=4096; ng build portal --prod",
"build:identity": "export NODE_OPTIONS=--max_old_space_size=4096; ng build identity --prod --output-path ../../../target/www/fr",
"build:ingest": "export NODE_OPTIONS=--max_old_space_size=4096; ng build ingest --prod --i18n-locale fr",
"build:archive-search": "export NODE_OPTIONS=--max_old_space_size=4096; ng build archive-search --prod --i18n-locale fr",
"build:referential": "export NODE_OPTIONS=--max_old_space_size=4096; ng build referential --prod --i18n-locale fr",
"build:pastis": "export NODE_OPTIONS=--max_old_space_size=4096; ng build pastis --prod --i18n-locale fr",
"analyze-portal": "ng build portal --stats-json --prod ; webpack-bundle-analyzer dist/portal/stats-es2015.json",
"analyze-identity": "ng build identity --stats-json --prod --i18n-locale fr ; webpack-bundle-analyzer dist/identity/stats-es2015.json",
"analyze-referential": "ng build referential --stats-json --prod --i18n-locale fr ; webpack-bundle-analyzer dist/referential/stats-es2015.json",
"analyze-ingest": "ng build ingest --stats-json --prod --i18n-locale fr ; webpack-bundle-analyzer dist/ingest/stats-es2015.json",
"analyze-archive-search": "ng build archive-search --stats-json --prod --i18n-locale fr ; webpack-bundle-analyzer dist/archive-search/stats-es2015.json",
"test": "ng test --watch=false",
"test:demo": "ng test demo --watch=false",
"test:portal": "ng test portal --watch=false",
"test:identity": "ng test identity --watch=false",
"test:ingest": "ng test ingest --watch=false",
"test:referential": "ng test referential --watch=false",
"test:archive-search": "ng test archive-search --watch=false",
"test:pastis": "ng test pastis --watch=false",
"test:vitamui-library": "ng test vitamui-library --watch=false",
"test:conf-ci": "ng test --watch=false --karma-config=karma.conf.ci.js",
"test:sonar": "ng test --code-coverage --watch=false",
"lint": "ng lint --format=stylish",
"lint:demo": "ng lint demo --format=stylish",
"lint:identity": "ng lint identity --format=stylish",
"lint:ingest": "ng lint ingest --format=stylish",
"lint:portal": "ng lint portal --format=stylish",
"lint:archive-search": "ng lint archive-search --format=stylish",
"lint:referential": "ng lint referential --format=stylish",
"lint:pastis": "ng lint pastis --format=stylish",
"lint:vitamui-library": "ng lint vitamui-library --format=stylish",
"e2e": "ng e2e",
"i18n-extract": "ng xi18n --outputPath=locale --i18n-locale=fr",
"i18n-merge": "xliffmerge --profile xliffmerge.json fr en",
"i18n:identity": "ng xi18n identity --outputPath=src/locale --i18n-locale=fr && xliffmerge --profile projects/identity/xliffmerge.json fr en",
"i18n:ingest": "ng xi18n ingest --outputPath=src/locale --i18n-locale=fr && xliffmerge --profile projects/ingest/xliffmerge.json fr en",
"i18n:archive-search": "ng xi18n archive-search --outputPath=src/locale --i18n-locale=fr && xliffmerge --profile projects/archive-search/xliffmerge.json fr en",
"i18n:referential": "ng xi18n referential --outputPath=src/locale --i18n-locale=fr && xliffmerge --profile projects/referential/xliffmerge.json fr en",
"i18n:pastis": "ng xi18n pastis --outputPath=src/locale --i18n-locale=fr && xliffmerge --profile projects/pastis/xliffmerge.json fr en",
"check:demo": "npm run lint:demo && npm run build:demo",
"check:portal": "npm run lint:portal && npm run test:portal && npm run build:portal",
"check:identity": "npm run lint:identity && npm run test:identity && npm run build:identity",
"extract-translations": "ngx-translate-extract --input ./projects/portal/src --output ./projects/portal/src/assets/i18n/*.json --sort --format namespaced-json --key-as-default-value",
"check:referential": "npm run lint:referential && npm run test:referential && npm run build:referential",
"check:archive-search": "npm run lint:archive-search && npm run test:archive-search && npm run build:archive-search",
"copy-scss:vitamui-library": "cp-cli ./projects/vitamui-library/src/sass ./dist/sass",
"build:vitamui-library": "ng build vitamui-library",
"watch:vitamui-library": "ng build vitamui-library --watch"
......@@ -52,6 +104,7 @@
"bootstrap": "^4.5.0",
"bufferutil": "^4.0.1",
"classlist.js": "^1.1.20150312",
"colors": "1.4.0",
"core-js": "^2.6.11",
"d3": "^3.5.17",
"d3-svg-legend": "^1.13.0",
......@@ -103,7 +156,7 @@
"jasmine-marbles": "^0.4.1",
"jasmine-spec-reporter": "~4.2.1",
"json-server": "^0.16.3",
"karma": "^5.0.9",
"karma": "^6.3.12",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "~2.1.1",
"karma-jasmine": "^2.0.1",
......@@ -120,5 +173,8 @@
"tslint": "~5.11.0",
"typescript": "~4.0.5",
"webpack-bundle-analyzer": "^3.8.0"
},
"overrides": {
"colors": "1.4.0"
}
}
package fr.gouv.vitamui.pastis;
import fr.gouv.vitamui.pastis.config.PastisApplicationProperties;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.info.BuildProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.core.env.Environment;