/*
 * Copyright 2015-2017 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.junit.platform.console.tasks;

import static org.junit.platform.commons.meta.API.Usage.Internal;

import org.junit.platform.commons.meta.API;
import org.junit.platform.engine.TestExecutionResult;
import org.junit.platform.launcher.TestIdentifier;

/**
 * @since 1.0
 */
@API(Internal)
enum Color {

	NONE(0),

	BLACK(30),

	RED(31),

	GREEN(32),

	YELLOW(33),

	BLUE(34),

	PURPLE(35),

	CYAN(36),

	WHITE(37);

	static Color valueOf(TestExecutionResult result) {
		switch (result.getStatus()) {
			case SUCCESSFUL:
				return Color.SUCCESSFUL;
			case ABORTED:
				return Color.ABORTED;
			case FAILED:
				return Color.FAILED;
			default:
				return Color.NONE;
		}
	}

	static Color valueOf(TestIdentifier testIdentifier) {
		return testIdentifier.isContainer() ? CONTAINER : TEST;
	}

	static Color SUCCESSFUL = GREEN;

	static Color ABORTED = YELLOW;

	static Color FAILED = RED;

	static Color SKIPPED = PURPLE;

	static Color CONTAINER = CYAN;

	static Color TEST = BLUE;

	static Color DYNAMIC = PURPLE;

	static Color REPORTED = WHITE;

	private final String ansiString;

	Color(int ansiCode) {
		this.ansiString = "\u001B[" + ansiCode + "m";
	}

	@Override
	public String toString() {
		return this.ansiString;
	}

}

@@ -1112,24 +1112,30 @@
 %09%7D%0A%0A%09static 
+final 
 Color SUCCES
@@ -1153,24 +1153,30 @@
 N;%0A%0A%09static 
+final 
 Color ABORTE
@@ -1192,24 +1192,30 @@
 W;%0A%0A%09static 
+final 
 Color FAILED
@@ -1227,24 +1227,30 @@
 D;%0A%0A%09static 
+final 
 Color SKIPPE
@@ -1266,24 +1266,30 @@
 E;%0A%0A%09static 
+final 
 Color CONTAI
@@ -1305,24 +1305,30 @@
 N;%0A%0A%09static 
+final 
 Color TEST =
@@ -1339,24 +1339,30 @@
 E;%0A%0A%09static 
+final 
 Color DYNAMI
@@ -1378,24 +1378,30 @@
 E;%0A%0A%09static 
+final 
 Color REPORT

Apply `final` modifiers to Color static instances (#930)