FederationPolicyInitializationContextValidator { public static void validate( FederationPolicyInitializationContext policyContext, String myType) throws FederationPolicyInitializationException { if (myType == null) { throw new FederationPolicyInitializationException( "The myType parameter" + " should not be null."); } if (policyContext == null) { throw new FederationPolicyInitializationException( "The FederationPolicyInitializationContext provided is null. Cannot" + " reinitalize " + "successfully."); } if (policyContext.getFederationStateStoreFacade() == null) { throw new FederationPolicyInitializationException( "The FederationStateStoreFacade provided is null. Cannot" + " reinitalize successfully."); } if (policyContext.getFederationSubclusterResolver() == null) { throw new FederationPolicyInitializationException( "The FederationSubclusterResolver provided is null. Cannot" + " reinitalize successfully."); } if (policyContext.getSubClusterPolicyConfiguration() == null) { throw new FederationPolicyInitializationException( "The SubClusterPolicyConfiguration provided is null. Cannot " + "reinitalize successfully."); } String intendedType = policyContext.getSubClusterPolicyConfiguration().getType(); if (!myType.equals(intendedType)) { throw new FederationPolicyInitializationException( "The FederationPolicyConfiguration carries a type (" + intendedType + ") different then mine (" + myType + "). Cannot reinitialize successfully."); } } private  FederationPolicyInitializationContextValidator(); static void validate(
      FederationPolicyInitializationContext policyContext, String myType);  }
@Test public void correcInit() throws Exception { FederationPolicyInitializationContextValidator.validate(context, MockPolicyManager.class.getCanonicalName()); }
@Test(expected = FederationPolicyInitializationException.class) public void nullContext() throws Exception { FederationPolicyInitializationContextValidator.validate(null, MockPolicyManager.class.getCanonicalName()); }
@Test(expected = FederationPolicyInitializationException.class) public void nullType() throws Exception { FederationPolicyInitializationContextValidator.validate(context, null); }
@Test(expected = FederationPolicyInitializationException.class) public void wrongType() throws Exception { FederationPolicyInitializationContextValidator.validate(context, "WrongType"); }
@Test(expected = FederationPolicyInitializationException.class) public void nullConf() throws Exception { context.setSubClusterPolicyConfiguration(null); FederationPolicyInitializationContextValidator.validate(context, MockPolicyManager.class.getCanonicalName()); }
@Test(expected = FederationPolicyInitializationException.class) public void nullResolver() throws Exception { context.setFederationSubclusterResolver(null); FederationPolicyInitializationContextValidator.validate(context, MockPolicyManager.class.getCanonicalName()); }
@Test(expected = FederationPolicyInitializationException.class) public void nullFacade() throws Exception { context.setFederationStateStoreFacade(null); FederationPolicyInitializationContextValidator.validate(context, MockPolicyManager.class.getCanonicalName()); }