869a36e2649ae064c98063cf1e55198488d78d12Allan Foster/**
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster *
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster *
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * The contents of this file are subject to the terms
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * of the Common Development and Distribution License
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * (the License). You may not use this file except in
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * compliance with the License.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster *
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * You can obtain a copy of the License at
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * opensso/legal/CDDLv1.0.txt
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * See the License for the specific language governing
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * permission and limitations under the License.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster *
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * When distributing Covered Code, include this CDDL
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * Header Notice in each file and include the License file
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * at opensso/legal/CDDLv1.0.txt.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * If applicable, add the following below the CDDL Header,
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * with the fields enclosed by brackets [] replaced by
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * your own identifying information:
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster *
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * $Id: OrSubjectTest.java,v 1.1 2009/08/19 05:41:00 veiming Exp $
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster */
6909255a1970175507277a0f2f105979625f76b2Jaco Jooste
6909255a1970175507277a0f2f105979625f76b2Jaco Jooste/**
6909255a1970175507277a0f2f105979625f76b2Jaco Jooste * Portions copyright 2014 ForgeRock AS.
6909255a1970175507277a0f2f105979625f76b2Jaco Jooste */
6909255a1970175507277a0f2f105979625f76b2Jaco Jooste
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterpackage com.sun.identity.entitlement;
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterimport java.util.HashSet;
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterimport java.util.Set;
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterimport org.testng.annotations.Test;
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster/**
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster *
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * @author dillidorai
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster */
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterpublic class OrSubjectTest {
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster @Test
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster public void testConstruction() throws Exception {
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster UserSubject us1 = new UserSubject("user11");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster us1.setPSubjectName("u1");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster UserSubject us2 = new UserSubject("user12");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster us2.setPSubjectName("u1");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster GroupSubject gs1 = new GroupSubject("group11");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster gs1.setPSubjectName("g1");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster GroupSubject gs2 = new GroupSubject("group12");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster gs1.setPSubjectName("g1");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster GroupSubject gs3 = new GroupSubject("group31");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster gs1.setPSubjectName("g3");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster Set<EntitlementSubject> subjects = new HashSet<EntitlementSubject>();
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster subjects.add(us1);
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster subjects.add(us2);
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster subjects.add(gs1);
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster subjects.add(gs2);
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster OrSubject os = new OrSubject(subjects);
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster OrSubject os1 = new OrSubject();
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster os1.setState(os.getState());
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster boolean result = os.equals(os1);
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster if (!result) {
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster throw new Exception("OrSubjectTest.testConstruction():"
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster + "OrSubject with setState="
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster + "does not equal OrSubject with getState()");
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster }
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster }
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster}