this.subsystem = getOrCreateSubsystem();
signet.beginTransaction(); createMetadata(signet); signet.commit();
  public Fixtures(Signet signet)  throws  	OperationNotSupportedException,  	SignetAuthorityException,  	ObjectNotFoundException,    HibernateException,    ClassNotFoundException,    SQLException  {    super();    this.signet = signet;        // Let's start with a clean slate of Assignments. This will help us    // to more reliably predict the number of duplicate Assignments later,    // while testing Assignment.findDuplicates().    deleteAssignmentsAndProxies();        this.subsystem = getOrCreateSubsystem();        tree = this.signet.getTree(Constants.TREE_ID);    this.subsystem.setTree(this.tree);        for (int i = 0; i < Constants.MAX_CATEGORIES; i++)    {      Category category = getOrCreateCategory(i);     }        for (int i = 0; i < Constants.MAX_CHOICE_SETS; i++)    {      ChoiceSet choiceSet = getOrCreateChoiceSet(i);     }        for (int i = 0; i < Constants.MAX_LIMITS; i++)    {      Limit limit = getOrCreateLimit(i);    }        for (int i = 0; i < Constants.MAX_FUNCTIONS; i++)    {      Function function = getOrCreateFunction(i);    }        for (int permissionNum = 0;         permissionNum < Constants.MAX_PERMISSIONS;         permissionNum++)    {      Permission permission = getOrCreatePermission(permissionNum);            // Permission 0 is associated with Limit 0 and Function 0,      // Permission 1 is associated with Limits 0 and 1 and Function 1,      // and so on.      getOrCreateFunction(permissionNum).addPermission(permission);            for (int limitNum = 0; limitNum <= permissionNum; limitNum++)      {        permission.addLimit(getOrCreateLimit(limitNum));      }    }        this.subsystem.save();        PrivilegedSubject sysAdmin      = designateSysAdmin(SYSADMIN_SUBJECT_NUMBER);        sysAdmin.setActingAs(signet.getSignetSubject());        PrivilegedSubject subsystemOwner      = designateSubsystemOwner          (sysAdmin,           SUBSYSTEM_OWNER_SUBJECT_NUMBER,           subsystem);        subsystemOwner.setActingAs(signet.getSignetSubject());        for (int i = 0; i < Constants.MAX_SUBJECTS; i++)    {      Assignment assignment = getOrCreateAssignment(subsystemOwner, i);      assignment.save();    }        for (int i = 0; i < Constants.MAX_SUBJECTS; i++)    {      // Each Subject grants a Proxy to the next Subject, except that the      // last Subject grants a Proxy to the first Subject.      //      // Each Proxy is for the test Subsystem, except that the last      // Subject grants a non-Subsystem-restricted Proxy to the first      // Subject.      int       grantorNumber = i;      int       granteeNumber;      Subsystem proxiedSubsystem;            if (i == (Constants.MAX_SUBJECTS-1))      {        granteeNumber = 0;        proxiedSubsystem = null;      }      else      {        granteeNumber = i+1;        proxiedSubsystem = signet.getSubsystem(Constants.SUBSYSTEM_ID);      }            Proxy proxy        = getOrCreateProxy(grantorNumber, granteeNumber, proxiedSubsystem);      proxy.save();    }        // This is intended to create an Assignment for Subject 0 that can    // be edited by Subject 2, but does not allow Subject 0 to edit the    // similar (but using different Limit-values) Assignment held by    // Subject 2.    int[] limitChoiceNumbers = {0, 0, 0};    Assignment assignment    	= getOrCreateAssignment    			(subsystemOwner,           0,  // subject-number    			 2,  // function-number    			 limitChoiceNumbers);    assignment.save();        // Grant and immediately revoke an Assignment from subject0 to subject2.    // This will come in handy later for testing the Assignment.getRevoker()    // method.    int[] limitChoiceNumbersForRevocation = {0};    PrivilegedSubject pSubject0 = Common.getPrivilegedSubject(signet, 0);    Assignment assignmentForRevocation      = getOrCreateAssignment          (pSubject0,           2, // grantee subject number           0,           limitChoiceNumbersForRevocation);    assignmentForRevocation.save();    assignmentForRevocation.revoke(pSubject0);    assignmentForRevocation.save();        // Grant and immediately revoke a Proxy from subject0 to subject2.    // This will come in handy later for testing the Proxy.getRevoker()    // method.    Proxy proxyForRevocation      = getOrCreateProxy          (0, // grantor subject number           2, // grantee subject number           this.subsystem);    proxyForRevocation.save();    proxyForRevocation.revoke(pSubject0);    proxyForRevocation.save();  }