Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void emptyXmlFolder() {
@Test
public void testConstructor() throws TmfConfigurationException {
// Make sure that an xml file is loaded
ITmfConfiguration config = sfXmlConfigSource.create(VALID_PARAM);
ITmfConfiguration config = sfXmlConfigSource.create(createConfig("valid params", VALID_PARAM));

XmlConfigurationSource instance = new XmlConfigurationSource();
List<ITmfConfiguration> configurations = instance.getConfigurations();
Expand Down Expand Up @@ -155,7 +155,7 @@ public void testCreation() {
// Test missing path
Map<String, Object> param = Collections.emptyMap();
try {
sfXmlConfigSource.create(param);
sfXmlConfigSource.create(createConfig("empty params", param));
} catch (TmfConfigurationException e) {
// success
assertEquals(EXPECTED_MESSAGE_NO_PATH, e.getMessage());
Expand All @@ -164,21 +164,21 @@ public void testCreation() {
// Test XML file doesn't exist
param = ImmutableMap.of(EXPECTED_KEY_NAME, XmlUtils.getXmlFilesPath().append(UNKNOWN_TYPE).toOSString());
try {
sfXmlConfigSource.create(param);
sfXmlConfigSource.create(createConfig("xml not exists params", param));
} catch (TmfConfigurationException e) {
// success
assertEquals(EXPECTED_MESSAGE_FILE_NOT_FOUND, e.getMessage());
}

// Test invalid XML file
try {
sfXmlConfigSource.create(INVALID_PARAM);
sfXmlConfigSource.create(createConfig("invalid params", INVALID_PARAM));
} catch (TmfConfigurationException e) {
// success
}

try {
ITmfConfiguration config = sfXmlConfigSource.create(VALID_PARAM);
ITmfConfiguration config = sfXmlConfigSource.create(createConfig("valid params", VALID_PARAM));
validateConfig(PATH_TO_VALID_FILE, config);
} catch (TmfConfigurationException e) {
fail();
Expand Down Expand Up @@ -248,15 +248,15 @@ public void testUpdate() {
// Test missing path
Map<String, Object> param = Collections.emptyMap();
try {
sfXmlConfigSource.update(config.getId(), param);
sfXmlConfigSource.update(config.getId(), createConfig("missing path params", param));
} catch (TmfConfigurationException e) {
// success
assertEquals(EXPECTED_MESSAGE_NO_PATH, e.getMessage());
}

// Test config doesn't exist
try {
sfXmlConfigSource.update(UNKNOWN_TYPE, param);
sfXmlConfigSource.update(UNKNOWN_TYPE, createConfig("config doesn't exists params", param));
} catch (TmfConfigurationException e) {
// success
assertEquals(EXPECTED_MESSAGE_INVALID_CONFIG, e.getMessage());
Expand All @@ -265,29 +265,29 @@ public void testUpdate() {
// Test XML file doesn't exist
param = ImmutableMap.of(EXPECTED_KEY_NAME, XmlUtils.getXmlFilesPath().append(UNKNOWN_TYPE).toOSString());
try {
sfXmlConfigSource.update(config.getId(), param);
sfXmlConfigSource.update(config.getId(), createConfig("xml file doesn't exists params", param));
} catch (TmfConfigurationException e) {
// success
assertEquals(EXPECTED_MESSAGE_FILE_NOT_FOUND, e.getMessage());
}

// Test invalid XML file
try {
sfXmlConfigSource.update(EXPECTED_CONFIG_ID, INVALID_PARAM);
sfXmlConfigSource.update(EXPECTED_CONFIG_ID, createConfig("invalid params", INVALID_PARAM));
} catch (TmfConfigurationException e) {
// success

}

// Test file name mismatch... not allowed to use different xmlfile name
try {
sfXmlConfigSource.update(config.getId(), VALID_PARAM2);
sfXmlConfigSource.update(config.getId(), createConfig("valid params 2", VALID_PARAM2));
} catch (TmfConfigurationException e) {
assertEquals(EXPECTED_MESSAGE_FILE_MISMATCH, e.getMessage());
}

try {
ITmfConfiguration configUpdated = sfXmlConfigSource.update(config.getId(), VALID_PARAM);
ITmfConfiguration configUpdated = sfXmlConfigSource.update(config.getId(), createConfig("valid params", VALID_PARAM));
validateConfig(PATH_TO_VALID_FILE, configUpdated);
} catch (TmfConfigurationException e) {
fail();
Expand Down Expand Up @@ -333,7 +333,7 @@ public void testGetConfiguration() {
private static ITmfConfiguration createConfig(String path) {
Map<String, Object> param = ImmutableMap.of("path", path);
try {
return sfXmlConfigSource.create(param);
return sfXmlConfigSource.create(createConfig("valid params with path", param));
} catch (TmfConfigurationException e) {
// Nothing to do
}
Expand All @@ -355,4 +355,14 @@ private static String getPath(Path folder, String name) {
assertTrue(file.exists());
return Objects.requireNonNull(file.getAbsolutePath());
}

private static ITmfConfiguration createConfig(String name, Map<String, Object> param) {
return new TmfConfiguration.Builder()
.setName(name)
.setDescription(name + " description")
.setSourceTypeId(XML_ANALYSIS_TYPE_ID)
.setParameters(param)
.build();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public interface ITmfConfigurationSource {
* @return a new {@link ITmfConfiguration} if successful
* @throws TmfConfigurationException
* If the creation of the configuration fails
* @deprecated As of version 10.0, use {@link #create(ITmfConfiguration)} instead
*/
@Deprecated(since = "10.0", forRemoval = true)
ITmfConfiguration create(Map<String, Object> parameters) throws TmfConfigurationException;

/**
Expand Down Expand Up @@ -78,7 +80,9 @@ default ITmfConfiguration create(ITmfConfiguration configuration) throws TmfConf
* @return a new {@link ITmfConfiguration} if successful
* @throws TmfConfigurationException
* If the update of the configuration fails
* @deprecated As of version 10.0, use {@link #update(String, ITmfConfiguration)} instead
*/
@Deprecated(since = "10.0", forRemoval = true)
ITmfConfiguration update(String id, Map<String, Object> parameters) throws TmfConfigurationException;

/**
Expand Down
Loading