|
48 | 48 | import static java.util.Collections.emptyList;
|
49 | 49 | import static java.util.stream.Collectors.joining;
|
50 | 50 |
|
| 51 | +/** |
| 52 | + * Outputs Teamcity services messages to std out. |
| 53 | + * |
| 54 | + * @see <a |
| 55 | + * href=https://www.jetbrains.com/help/teamcity/service-messages.html>TeamCity |
| 56 | + * - Service Messages</a> |
| 57 | + */ |
51 | 58 | public class TeamCityPlugin implements EventListener {
|
52 | 59 |
|
53 | 60 | private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'hh:mm:ss.SSSZ");
|
@@ -250,22 +257,27 @@ private void printTestStepFinished(TestStepFinished event) {
|
250 | 257 | Throwable error = event.getResult().getError();
|
251 | 258 | Status status = event.getResult().getStatus();
|
252 | 259 | switch (status) {
|
253 |
| - case SKIPPED: |
254 |
| - print(TEMPLATE_TEST_IGNORED, timeStamp, duration, error == null ? "Step skipped" : error.getMessage(), |
255 |
| - name); |
| 260 | + case SKIPPED: { |
| 261 | + String message = error == null ? "Step skipped" : error.getMessage(); |
| 262 | + print(TEMPLATE_TEST_IGNORED, timeStamp, duration, message, name); |
256 | 263 | break;
|
257 |
| - case PENDING: |
258 |
| - print(TEMPLATE_TEST_IGNORED, timeStamp, duration, error == null ? "Step pending" : error.getMessage(), |
259 |
| - name); |
| 264 | + } |
| 265 | + case PENDING: { |
| 266 | + String details = error == null ? "" : error.getMessage(); |
| 267 | + print(TEMPLATE_TEST_FAILED, timeStamp, duration, "Step pending", details, name); |
260 | 268 | break;
|
261 |
| - case UNDEFINED: |
262 |
| - print(TEMPLATE_TEST_FAILED, timeStamp, duration, "Step undefined", getSnippets(currentTestCase), name); |
| 269 | + } |
| 270 | + case UNDEFINED: { |
| 271 | + String snippets = getSnippets(currentTestCase); |
| 272 | + print(TEMPLATE_TEST_FAILED, timeStamp, duration, "Step undefined", snippets, name); |
263 | 273 | break;
|
| 274 | + } |
264 | 275 | case AMBIGUOUS:
|
265 |
| - case FAILED: |
| 276 | + case FAILED: { |
266 | 277 | String details = extractStackTrace(error);
|
267 | 278 | print(TEMPLATE_TEST_FAILED, timeStamp, duration, "Step failed", details, name);
|
268 | 279 | break;
|
| 280 | + } |
269 | 281 | default:
|
270 | 282 | break;
|
271 | 283 | }
|
@@ -307,8 +319,8 @@ private String getSnippets(TestCase testCase) {
|
307 | 319 | URI uri = testCase.getUri();
|
308 | 320 | Location location = testCase.getLocation();
|
309 | 321 | List<Suggestion> suggestionForTestCase = suggestions.stream()
|
310 |
| - .filter(suggestions -> suggestions.getUri().equals(uri) && |
311 |
| - suggestions.getTestCaseLocation().equals(location)) |
| 322 | + .filter(suggestion -> suggestion.getUri().equals(uri) && |
| 323 | + suggestion.getTestCaseLocation().equals(location)) |
312 | 324 | .map(SnippetsSuggestedEvent::getSuggestion)
|
313 | 325 | .collect(Collectors.toList());
|
314 | 326 | return createMessage(suggestionForTestCase);
|
@@ -379,7 +391,7 @@ private String formatCommand(String command, Object... parameters) {
|
379 | 391 | escapedParameters[i] = escape(parameters[i].toString());
|
380 | 392 | }
|
381 | 393 |
|
382 |
| - return String.format(command, escapedParameters); |
| 394 | + return String.format(command, (Object[]) escapedParameters); |
383 | 395 | }
|
384 | 396 |
|
385 | 397 | private String escape(String source) {
|
|
0 commit comments