/*
 * Copyright (c) 2012 Socialize Inc.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package com.socialize.test.unit.facebook;

import com.socialize.auth.facebook.FacebookAuthProviderInfo;
import com.socialize.test.SocializeUnitTest;


/**
 * @author Jason Polites
 *
 */
public class FacebookAuthProviderInfoTest extends SocializeUnitTest {

	public void testEquals() {
		FacebookAuthProviderInfo info0 = new FacebookAuthProviderInfo();
		FacebookAuthProviderInfo info1 = new FacebookAuthProviderInfo();
		FacebookAuthProviderInfo info2 = new FacebookAuthProviderInfo();
		
		info0.setAppId("abc");
		info1.setAppId("abc");
		info2.setAppId("def");
		
		assertTrue(info0.equals(info0));
		assertTrue(info0.equals(info1));
		assertFalse(info0.equals(info2));
	}
	
	public void testMatches() {
		FacebookAuthProviderInfo info0 = new FacebookAuthProviderInfo();
		FacebookAuthProviderInfo info1 = new FacebookAuthProviderInfo();
		FacebookAuthProviderInfo info2 = new FacebookAuthProviderInfo();
		
		info0.setAppId("abc");
		info1.setAppId("abc");
		info2.setAppId("abc");
		
		info0.setPermissions(new String[]{"a","b","c"});
		info1.setPermissions(new String[]{"b","c"});
		info2.setPermissions(new String[]{"c","a","b"});
		
		
		assertTrue(info0.matches(info1));
		assertTrue(info0.matches(info2));
		
		assertTrue(info2.matches(info1));
		assertTrue(info2.matches(info0));
		
		assertFalse(info1.matches(info2));
		assertFalse(info1.matches(info0));
	}
	
}

@@ -1219,16 +1219,92 @@
 erInfo;%0A
+import com.socialize.auth.facebook.FacebookAuthProviderInfo.PermissionType;%0A
 import c
@@ -1340,16 +1340,16 @@
 itTest;%0A
-
 %0A%0A/**%0A *
@@ -1894,16 +1894,20 @@
 tMatches
+Read
 () %7B%0A%09%09F
@@ -2192,24 +2192,28 @@
 %0A%09%09info0.set
+Read
 Permissions(
@@ -2247,24 +2247,28 @@
 %0A%09%09info1.set
+Read
 Permissions(
@@ -2302,16 +2302,20 @@
 nfo2.set
+Read
 Permissi
@@ -2576,15 +2576,879 @@
 nfo0));%0A
-
 %09%7D%0A%09%0A
+%09public void testMatchesWrite() %7B%0A%09%09FacebookAuthProviderInfo info0 = new FacebookAuthProviderInfo();%0A%09%09FacebookAuthProviderInfo info1 = new FacebookAuthProviderInfo();%0A%09%09FacebookAuthProviderInfo info2 = new FacebookAuthProviderInfo();%0A%09%09%0A%09%09info0.setAppId(%22abc%22);%0A%09%09info1.setAppId(%22abc%22);%0A%09%09info2.setAppId(%22abc%22);%0A%09%09%0A%09%09info0.setWritePermissions(new String%5B%5D%7B%22a%22,%22b%22,%22c%22%7D);%0A%09%09info1.setWritePermissions(new String%5B%5D%7B%22b%22,%22c%22%7D);%0A%09%09info2.setReadPermissions(new String%5B%5D%7B%22c%22,%22a%22,%22b%22%7D);%0A%09%09%0A%09%09info0.setPermissionType(PermissionType.WRITE);%0A%09%09info1.setPermissionType(PermissionType.WRITE);%0A%09%09info2.setPermissionType(PermissionType.READ);%0A%09%09%0A%09%09assertTrue(info0.matches(info1));%0A%09%09assertFalse(info0.matches(info2));%0A%09%09%0A%09%09assertFalse(info2.matches(info1));%0A%09%09assertFalse(info2.matches(info0));%0A%09%09%0A%09%09assertFalse(info1.matches(info2));%0A%09%09assertFalse(info1.matches(info0));%0A%09%7D%09%0A%09%0A
 %7D%0A

Test fixes