Skip to content

Commit f00d987

Browse files
committed
tmf.config: deprecate create/update methods with parameter map
Use the corresponding methods with ITmfConfiguration instead [Deprecated] create/update methods with parameter map Signed-off-by: Bernd Hufmann <[email protected]>
1 parent fe50f3f commit f00d987

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/config/XmlConfigurationSourceTest.java

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void emptyXmlFolder() {
121121
@Test
122122
public void testConstructor() throws TmfConfigurationException {
123123
// Make sure that an xml file is loaded
124-
ITmfConfiguration config = sfXmlConfigSource.create(VALID_PARAM);
124+
ITmfConfiguration config = sfXmlConfigSource.create(createConfig("valid params", VALID_PARAM));
125125

126126
XmlConfigurationSource instance = new XmlConfigurationSource();
127127
List<ITmfConfiguration> configurations = instance.getConfigurations();
@@ -155,7 +155,7 @@ public void testCreation() {
155155
// Test missing path
156156
Map<String, Object> param = Collections.emptyMap();
157157
try {
158-
sfXmlConfigSource.create(param);
158+
sfXmlConfigSource.create(createConfig("empty params", param));
159159
} catch (TmfConfigurationException e) {
160160
// success
161161
assertEquals(EXPECTED_MESSAGE_NO_PATH, e.getMessage());
@@ -164,21 +164,21 @@ public void testCreation() {
164164
// Test XML file doesn't exist
165165
param = ImmutableMap.of(EXPECTED_KEY_NAME, XmlUtils.getXmlFilesPath().append(UNKNOWN_TYPE).toOSString());
166166
try {
167-
sfXmlConfigSource.create(param);
167+
sfXmlConfigSource.create(createConfig("xml not exists params", param));
168168
} catch (TmfConfigurationException e) {
169169
// success
170170
assertEquals(EXPECTED_MESSAGE_FILE_NOT_FOUND, e.getMessage());
171171
}
172172

173173
// Test invalid XML file
174174
try {
175-
sfXmlConfigSource.create(INVALID_PARAM);
175+
sfXmlConfigSource.create(createConfig("invalid params", INVALID_PARAM));
176176
} catch (TmfConfigurationException e) {
177177
// success
178178
}
179179

180180
try {
181-
ITmfConfiguration config = sfXmlConfigSource.create(VALID_PARAM);
181+
ITmfConfiguration config = sfXmlConfigSource.create(createConfig("valid params", VALID_PARAM));
182182
validateConfig(PATH_TO_VALID_FILE, config);
183183
} catch (TmfConfigurationException e) {
184184
fail();
@@ -248,15 +248,15 @@ public void testUpdate() {
248248
// Test missing path
249249
Map<String, Object> param = Collections.emptyMap();
250250
try {
251-
sfXmlConfigSource.update(config.getId(), param);
251+
sfXmlConfigSource.update(config.getId(), createConfig("missing path params", param));
252252
} catch (TmfConfigurationException e) {
253253
// success
254254
assertEquals(EXPECTED_MESSAGE_NO_PATH, e.getMessage());
255255
}
256256

257257
// Test config doesn't exist
258258
try {
259-
sfXmlConfigSource.update(UNKNOWN_TYPE, param);
259+
sfXmlConfigSource.update(UNKNOWN_TYPE, createConfig("config doesn't exists params", param));
260260
} catch (TmfConfigurationException e) {
261261
// success
262262
assertEquals(EXPECTED_MESSAGE_INVALID_CONFIG, e.getMessage());
@@ -265,29 +265,29 @@ public void testUpdate() {
265265
// Test XML file doesn't exist
266266
param = ImmutableMap.of(EXPECTED_KEY_NAME, XmlUtils.getXmlFilesPath().append(UNKNOWN_TYPE).toOSString());
267267
try {
268-
sfXmlConfigSource.update(config.getId(), param);
268+
sfXmlConfigSource.update(config.getId(), createConfig("xml file doesn't exists params", param));
269269
} catch (TmfConfigurationException e) {
270270
// success
271271
assertEquals(EXPECTED_MESSAGE_FILE_NOT_FOUND, e.getMessage());
272272
}
273273

274274
// Test invalid XML file
275275
try {
276-
sfXmlConfigSource.update(EXPECTED_CONFIG_ID, INVALID_PARAM);
276+
sfXmlConfigSource.update(EXPECTED_CONFIG_ID, createConfig("invalid params", INVALID_PARAM));
277277
} catch (TmfConfigurationException e) {
278278
// success
279279

280280
}
281281

282282
// Test file name mismatch... not allowed to use different xmlfile name
283283
try {
284-
sfXmlConfigSource.update(config.getId(), VALID_PARAM2);
284+
sfXmlConfigSource.update(config.getId(), createConfig("valid params 2", VALID_PARAM2));
285285
} catch (TmfConfigurationException e) {
286286
assertEquals(EXPECTED_MESSAGE_FILE_MISMATCH, e.getMessage());
287287
}
288288

289289
try {
290-
ITmfConfiguration configUpdated = sfXmlConfigSource.update(config.getId(), VALID_PARAM);
290+
ITmfConfiguration configUpdated = sfXmlConfigSource.update(config.getId(), createConfig("valid params", VALID_PARAM));
291291
validateConfig(PATH_TO_VALID_FILE, configUpdated);
292292
} catch (TmfConfigurationException e) {
293293
fail();
@@ -333,7 +333,7 @@ public void testGetConfiguration() {
333333
private static ITmfConfiguration createConfig(String path) {
334334
Map<String, Object> param = ImmutableMap.of("path", path);
335335
try {
336-
return sfXmlConfigSource.create(param);
336+
return sfXmlConfigSource.create(createConfig("valid params with path", param));
337337
} catch (TmfConfigurationException e) {
338338
// Nothing to do
339339
}
@@ -355,4 +355,14 @@ private static String getPath(Path folder, String name) {
355355
assertTrue(file.exists());
356356
return Objects.requireNonNull(file.getAbsolutePath());
357357
}
358+
359+
private static ITmfConfiguration createConfig(String name, Map<String, Object> param) {
360+
return new TmfConfiguration.Builder()
361+
.setName(name)
362+
.setDescription(name + " description")
363+
.setSourceTypeId(XML_ANALYSIS_TYPE_ID)
364+
.setParameters(param)
365+
.build();
366+
367+
}
358368
}

tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/config/ITmfConfigurationSource.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ public interface ITmfConfigurationSource {
4141
* @return a new {@link ITmfConfiguration} if successful
4242
* @throws TmfConfigurationException
4343
* If the creation of the configuration fails
44+
* @deprecated As of version 10.0, use {@link #create(ITmfConfiguration)} instead
4445
*/
46+
@Deprecated(since = "10.0", forRemoval = true)
4547
ITmfConfiguration create(Map<String, Object> parameters) throws TmfConfigurationException;
4648

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

8488
/**

0 commit comments

Comments
 (0)