package com.redhat.victims;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.Test;

import com.redhat.victims.fingerprint.Algorithms;

public class VictimsConfigTest {

	@Test
	public void testAlgorithms() {
		// test defaults
		ArrayList<Algorithms> results = VictimsConfig.algorithms();

		assertTrue("Unexpected default algorithm configuration.",
				results.contains(VictimsConfig.getDefaultAlgorithm()));

		// test legal set
		System.setProperty(VictimsConfig.Key.ALGORITHMS, "SHA512");
		results = VictimsConfig.algorithms();
		assertTrue("Algorithms were not set correctly.",
				results.contains(Algorithms.SHA512) && results.size() == 1);

		// test legal with illegal set
		System.setProperty(VictimsConfig.Key.ALGORITHMS, "MD1, SHA512");
		results = VictimsConfig.algorithms();
		assertTrue("Algorithms were not set correctly.",
				results.contains(Algorithms.SHA512) && results.size() == 1);

		// test all invalids
		System.setProperty(VictimsConfig.Key.ALGORITHMS, "MD1,DUMMY");
		results = VictimsConfig.algorithms();
		for (Algorithms alg : Algorithms.values()) {
			assertTrue(
					"All algorithms are invalid case did not return all defined algorithms.",
					results.contains(VictimsConfig.getDefaultAlgorithm()));
		}
	}

}

@@ -57,9 +57,18 @@
 ert.
-*
+assertTrue
 ;%0A%0Ai
@@ -1076,13 +1076,8 @@
 ;%0A%09%09
-for (
 Algo
@@ -1087,40 +1087,58 @@
 hms 
-alg : Algorithms.values()) %7B
+expected = VictimsConfig.getDefaultAlgorithm();
 %0A%09%09
-%09
 asse
@@ -1148,155 +1148,120 @@
 rue(
-%0A%09%09%09%09%09%22All algorithms are invalid case did not return all defined algorithms.%22,%0A%09%09%09%09%09results.contains(VictimsConfig.getDefaultAlgorithm()
+%22Unexpected algorithm(s) returned for invalid config.%22,%0A%09%09%09%09results.size() == 1 && results.contains(expected
 ));%0A
-%09
 %09%7D%0A
-%09%7D%0A%0A%7D%0A
+%7D

Fix Config test case