package com.github.aureliano.achmed.resources.properties;

import java.util.Arrays;

import org.junit.Assert;
import org.junit.Test;

import com.github.aureliano.achmed.resources.types.PackageProvider;

public class PackagePropertiesTest {

	@Test
	public void testConfigureAttributes() {
		PackageProperties pkg = (PackageProperties) new PackageProperties()
			.put("name", "pkg")
			.put("provider", PackageProvider.APT)
			.put("ensure", "latest")
			.put("installOptions", Arrays.asList("-i test"))
			.put("uninstallOptions", Arrays.asList("-u test"))
			.put("source", "src")
			.configureAttributes();
		
		Assert.assertEquals("pkg", pkg.getName());
		Assert.assertEquals(PackageProvider.APT, pkg.getProvider());
		Assert.assertEquals("latest", pkg.getEnsure());
		Assert.assertEquals(Arrays.asList("-i test"), pkg.getInstallOptions());
		Assert.assertEquals(Arrays.asList("-u test"), pkg.getUninstallOptions());
		Assert.assertEquals("src", pkg.getSource());
	}

	@Test
	public void testHashCode() {
		PackageProperties p1 = new PackageProperties();
		PackageProperties p2 = new PackageProperties();
		
		Assert.assertEquals(p1.hashCode(), p2.hashCode());
		
		p1.setName("pkg");
		Assert.assertFalse(p1.hashCode() == p2.hashCode());
		
		p2.setName("pkg");
		Assert.assertTrue(p1.hashCode() == p2.hashCode());
		
		p1.setProvider(PackageProvider.APT);
		Assert.assertFalse(p1.hashCode() == p2.hashCode());
		
		p2.setProvider(PackageProvider.APT);
		Assert.assertTrue(p1.hashCode() == p2.hashCode());
	}
	
	@Test
	public void testEquals() {
		PackageProperties p1 = new PackageProperties();
		PackageProperties p2 = new PackageProperties();
		
		Assert.assertEquals(p1, p2);
		
		p1.setName("pkg");
		Assert.assertFalse(p1.equals(p2));
		
		p2.setName("pkg");
		Assert.assertTrue(p1.equals(p2));
		
		p1.setProvider(PackageProvider.APT);
		Assert.assertFalse(p1.equals(p2));
		
		p2.setProvider(PackageProvider.APT);
		Assert.assertTrue(p1.equals(p2));
	}
}
@@ -63,34 +63,140 @@
 ort 
-java.util.Arrays;%0A
+static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertNull;
 %0Aimport 
 org.
@@ -183,32 +183,39 @@
 ertNull;%0Aimport 
+static 
 org.junit.Assert
@@ -214,17 +214,55 @@
 t.Assert
-;
+.assertTrue;%0A%0Aimport java.util.Arrays;%0A
 %0Aimport 
@@ -750,39 +750,32 @@
 ributes();%0A%09%09%0A%09%09
-Assert.
 assertEquals(%22pk
@@ -788,39 +788,32 @@
 g.getName());%0A%09%09
-Assert.
 assertEquals(Pac
@@ -848,31 +848,24 @@
 vider());%0A%09%09
-Assert.
 assertEquals
@@ -891,31 +891,24 @@
 nsure());%0A%09%09
-Assert.
 assertEquals
@@ -954,39 +954,32 @@
 llOptions());%0A%09%09
-Assert.
 assertEquals(Arr
@@ -1027,31 +1027,24 @@
 tions());%0A%09%09
-Assert.
 assertEquals
@@ -1069,16 +1069,188 @@
 rce());%0A
+%09%09%0A%09%09pkg.setProvider(null);%0A%09%09assertNull(pkg.getProvider());%0A%09%09%0A%09%09pkg.put(%22provider%22, %22apt%22).configureAttributes();%0A%09%09assertEquals(PackageProvider.APT, pkg.getProvider());%0A
 %09%7D%0A%0A%09@Te
@@ -1379,39 +1379,32 @@
 perties();%0A%09%09%0A%09%09
-Assert.
 assertEquals(p1.
@@ -1449,39 +1449,32 @@
 tName(%22pkg%22);%0A%09%09
-Assert.
 assertFalse(p1.h
@@ -1520,39 +1520,32 @@
 tName(%22pkg%22);%0A%09%09
-Assert.
 assertTrue(p1.ha
@@ -1608,39 +1608,32 @@
 rovider.APT);%0A%09%09
-Assert.
 assertFalse(p1.h
@@ -1697,39 +1697,32 @@
 rovider.APT);%0A%09%09
-Assert.
 assertTrue(p1.ha
@@ -1894,23 +1894,16 @@
 );%0A%09%09%0A%09%09
-Assert.
 assertEq
@@ -1938,31 +1938,24 @@
 e(%22pkg%22);%0A%09%09
-Assert.
 assertFalse(
@@ -1992,31 +1992,24 @@
 e(%22pkg%22);%0A%09%09
-Assert.
 assertTrue(p
@@ -2063,31 +2063,24 @@
 der.APT);%0A%09%09
-Assert.
 assertFalse(
@@ -2139,23 +2139,16 @@
 APT);%0A%09%09
-Assert.
 assertTr

Enhance unit test.