package com.github.aureliano.achmed.helper;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.util.List;

import org.junit.Test;

import com.github.aureliano.achmed.resources.ExecResource;
import com.github.aureliano.achmed.resources.FileResource;
import com.github.aureliano.achmed.resources.IResource;
import com.github.aureliano.achmed.resources.PackageResource;
import com.github.aureliano.achmed.resources.ServiceResource;

public class ApplicationHelperTest {

	private static final String RESOURCES_DIR = "src/test/resources";
	
	@Test
	public void testBuildAllResources() {
		String path = this.buildPath(RESOURCES_DIR, "yaml", "main.yaml");
		List<IResource> resources = ApplicationHelper.buildAllResources(path);
		
		int expectedResources = 4;
		assertEquals(expectedResources, resources.size());
		
		assertTrue(resources.get(0) instanceof ExecResource);
		assertTrue(resources.get(1) instanceof FileResource);
		assertTrue(resources.get(2) instanceof PackageResource);
		assertTrue(resources.get(3) instanceof ServiceResource);
	}
	
	@Test
	public void testHelp() {
		String help = ApplicationHelper.help();
		
		assertTrue(help.contains("Usage: [java -jar] achmed-x.x.x.jar burst [FILE]"));
		assertTrue(help.contains("-h        Print this message."));
		assertTrue(help.contains("-v        Print the version."));
		assertTrue(help.contains("--help    Print this message."));
		assertTrue(help.contains("--version Print the version."));
		assertTrue(help.contains("Required JVM 1.7 or higher."));
		assertTrue(help.contains("Example:"));
		assertTrue(help.contains("java -jar achmed-x.x.x.jar burst /path/to/schema.yaml"));
		assertTrue(help.contains("Get involved"));
		assertTrue(help.contains("- Source: https://github.com/aureliano/achmed"));
		assertTrue(help.contains("- Issues: https://github.com/aureliano/achmed/issues"));
		assertTrue(help.contains("- Wiki: https://github.com/aureliano/achmed/wiki for more detailed insights."));
	}
	
	private String buildPath(String...tokens) {
		return StringHelper.join(tokens, File.separator);
	}
}
@@ -2026,16 +2026,167 @@
 );%0A%09%7D%0A%09%0A
+%09@Test%0A%09public void testVersion() %7B%0A%09%09String version = ApplicationHelper.version();%0A%09%09assertTrue(version.contains(%220.1.0:BETA-01 (2015-12-15)%22));%0A%09%7D%0A%09%0A
 %09private

Add unit test to version method.