package org.openur.module.domain.security;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class OpenURPermissionTest
{
	@Test
	public void testCompareTo()
	{
		OpenURApplication app = new OpenURApplicationBuilder("app", "user1", "pw").build();		
		
		OpenURPermission perm1 = new OpenURPermissionBuilder("perm1", PermissionScope.SELECTED, app).build();		
		OpenURPermission perm2 = new OpenURPermissionBuilder("perm2", PermissionScope.SELECTED, app).build();
		
		assertTrue(perm1.compareTo(perm2) < 0);
	}
	
//	@Test(expected=IllegalArgumentException.class)
//	public void testExceptionCreateWithEmptyNameAndEmptyApp()
//	{
//		new OpenURPermissionBuilder("", null);
//	}
	
	@Test(expected=NullPointerException.class)
	public void testExceptionCreateWithNameAndEmptyApp()
	{
		new OpenURPermissionBuilder("perm", PermissionScope.SELECTED, null);
	}
	
	@Test(expected=NullPointerException.class)
	public void testExceptionCreateWithNameAndAppAndEmptyScope()
	{
		OpenURApplication app = new OpenURApplicationBuilder("app", "user1", "pw").build();
		new OpenURPermissionBuilder("perm", null, app);
	}
	
	@Test(expected=IllegalArgumentException.class)
	public void testExceptionCreateWithEmptyNameAndApp()
	{
		OpenURApplication app = new OpenURApplicationBuilder("app", "user1", "pw").build();
		new OpenURPermissionBuilder("", PermissionScope.SELECTED, app);
	}
}

@@ -185,38 +185,33 @@
 pareTo()%0D%0A%09%7B%0D%0A%09%09
-OpenUR
+I
 Application app 
@@ -277,30 +277,25 @@
 );%09%09%0D%0A%09%09%0D%0A%09%09
-OpenUR
+I
 Permission p
@@ -383,22 +383,17 @@
 );%09%09%0D%0A%09%09
-OpenUR
+I
 Permissi
@@ -996,38 +996,33 @@
 yScope()%0D%0A%09%7B%0D%0A%09%09
-OpenUR
+I
 Application app 
@@ -1252,22 +1252,17 @@
 %0D%0A%09%7B%0D%0A%09%09
-OpenUR
+I
 Applicat

use Domiain-Interfaces in test