string replace test
This commit is contained in:
parent
01bad9d30f
commit
122fd7c882
|
@ -1,6 +1,9 @@
|
|||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -8,6 +11,7 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.text.StringSubstitutor;
|
||||
import org.gcube.application.cms.notifications.substitutor.SubstitutorMessagesMap;
|
||||
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -24,26 +28,29 @@ public class StringReplacerTest {
|
|||
"MSG_ITEM_REJECTED_REVIEW_REQUIRED", "MSG_ITEM_PUBLISHED");
|
||||
|
||||
public static String USERNAME = "francesco.mangiacrapa";
|
||||
public static String PROJECT_ID = "12345";
|
||||
public static String PROJECT_NAME = "\"My Great Project\"";
|
||||
public static String GIS_LINK = "https://my_gis_link";
|
||||
|
||||
public static String FILE_URL = "https://code-repo.d4science.org/gCubeSystem/gcube-cms-suite/raw/branch/event_manager/D4S_UCDs/DEV/devVRE/notifications/Notifications_Messages.properties";
|
||||
|
||||
@Test
|
||||
public void checkReplace() {
|
||||
org.junit.Assume.assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
|
||||
if (GCubeTest.isTestInfrastructureEnabled()) {
|
||||
|
||||
Map<String, String> valuesMap = new HashMap<>();
|
||||
valuesMap.put("user", USERNAME);
|
||||
valuesMap.put("project_name", PROJECT_NAME);
|
||||
valuesMap.put("gis_link", GIS_LINK);
|
||||
valuesMap.put(SubstitutorMessagesMap.USER, USERNAME);
|
||||
valuesMap.put(SubstitutorMessagesMap.PROJECT_NAME, PROJECT_NAME);
|
||||
valuesMap.put(SubstitutorMessagesMap.GIS_LINK, GIS_LINK);
|
||||
valuesMap.put(SubstitutorMessagesMap.PROJECT_ID, PROJECT_ID);
|
||||
// Build StringSubstitutor
|
||||
StringSubstitutor sub = new StringSubstitutor(valuesMap);
|
||||
|
||||
try (InputStream input = new FileInputStream(NOTIFICATION_MESSAGE_FILE_PATH)) {
|
||||
try (BufferedInputStream in = new BufferedInputStream(new URL(FILE_URL).openStream())) {
|
||||
|
||||
Properties prop = new Properties();
|
||||
// load a properties file
|
||||
prop.load(input);
|
||||
prop.load(in);
|
||||
|
||||
for (String placeholder : PLACEHOLDERS) {
|
||||
log.info("placeholder: {}", placeholder);
|
||||
|
@ -54,9 +61,8 @@ public class StringReplacerTest {
|
|||
log.info("resolvedString: {}", resolvedString);
|
||||
}
|
||||
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue