예제 #1
0
 private GlobalIdentifier processGlobalIdentifier(MpiConfigDocument configuration) {
   globalIdentifier = new GlobalIdentifier();
   if (!configuration.getMpiConfig().isSetGlobalIdentifier()) {
     globalIdentifier.setAssignGlobalIdentifier(false);
     return globalIdentifier;
   }
   globalIdentifier.setAssignGlobalIdentifier(
       configuration.getMpiConfig().getGlobalIdentifier().getAssignGlobalIdentifier());
   globalIdentifier.setIdentifierDomainName(
       configuration.getMpiConfig().getGlobalIdentifier().getIdentifierDomainName());
   globalIdentifier.setIdentifierDomainDescription(
       configuration.getMpiConfig().getGlobalIdentifier().getIdentifierDomainDescription());
   globalIdentifier.setNamespaceIdentifier(
       configuration.getMpiConfig().getGlobalIdentifier().getNamespaceIdentifier());
   globalIdentifier.setUniversalIdentifier(
       configuration.getMpiConfig().getGlobalIdentifier().getUniversalIdentifier());
   globalIdentifier.setUniversalIdentifierType(
       configuration.getMpiConfig().getGlobalIdentifier().getUniversalIdentifierType());
   IdentifierDomain domain =
       Context.getPersonQueryService()
           .findIdentifierDomainByName(globalIdentifier.getIdentifierDomainName());
   if (domain == null) {
     log.error(
         "Global identifier domain not found; correct system configuration and start system again.");
     System.exit(-1);
   }
   globalIdentifier.setIdentifierDomain(domain);
   return globalIdentifier;
 }
예제 #2
0
 public IdentifierDomain getGlobalIdentifierDomain() {
   if (globalIdentifier == null) {
     throw new RuntimeException(
         "The global identifier configuration has not been specified in the configuration file.");
   }
   return globalIdentifier.getIdentifierDomain();
 }
예제 #3
0
  @Test
  public void testReadDomainsAndGuids() throws Exception {
    CustomerDAO dao = new CustomerDAO();
    IConfiguration configuration = EasyMock.createStrictMock(IConfiguration.class);
    dao.setConfiguration(configuration);
    ResultSet resultSet = EasyMock.createStrictMock(ResultSet.class);
    Set<String> domains = new HashSet<String>();
    Set<GlobalIdentifier> guids = new HashSet<GlobalIdentifier>();
    int custId = 34;
    int cloudService = 2;
    int replicationZone = 453;

    int cloudService2 = 1;
    int replicationZone2 = 13;

    int cloudService3 = 3;

    // first exec of loop
    EasyMock.expect(resultSet.getString(10)).andReturn("domain123");
    EasyMock.expect(resultSet.getString(11)).andReturn("guid123");
    EasyMock.expect(resultSet.getInt(12)).andReturn(cloudService);
    EasyMock.expect(resultSet.getInt(13)).andReturn(replicationZone);
    EasyMock.expect(resultSet.next()).andReturn(true);
    EasyMock.expect(resultSet.getInt(1)).andReturn(custId);

    // second exec of loop
    EasyMock.expect(resultSet.getString(10)).andReturn("domain456");
    EasyMock.expect(resultSet.getString(11)).andReturn("guid456");
    EasyMock.expect(resultSet.getInt(12)).andReturn(cloudService2);
    EasyMock.expect(resultSet.getInt(13)).andReturn(replicationZone2);
    EasyMock.expect(resultSet.next()).andReturn(true);
    EasyMock.expect(resultSet.getInt(1)).andReturn(custId);

    // third exec of loop (guid not valid with no cloud service)
    EasyMock.expect(resultSet.getString(10)).andReturn("domain456");
    EasyMock.expect(resultSet.getString(11)).andReturn("guid789");
    EasyMock.expect(resultSet.getInt(12)).andReturn(cloudService3);
    EasyMock.expect(resultSet.next()).andReturn(true);
    EasyMock.expect(resultSet.getInt(1)).andReturn(custId + 1); // ends loop with mismatched custid

    EasyMock.replay(resultSet);
    assertTrue(
        "Should have another item even.",
        dao.readDomainsAndGuids(resultSet, custId, domains, guids));
    EasyMock.verify(resultSet);
    assertEquals("Should have 2 domains.", 2, domains.size());
    assertTrue("Domain123 not found.", domains.contains("domain123"));
    assertTrue("Domain456 not found.", domains.contains("domain456"));

    assertEquals("Should have 2 guids.", 2, guids.size());
    for (GlobalIdentifier guid : guids) {
      if (guid.getGuid().equals("guid123")) {
        assertEquals("Wrong cloud service in guid123", CloudService.GOOGLE, guid.getService());
        assertEquals("Wrong replication zone.", replicationZone, guid.getReplicationZone());
      } else {
        assertEquals("Wrong cloud service in guid456", CloudService.OFFICE365, guid.getService());
        assertEquals("Wrong replication zone.", replicationZone2, guid.getReplicationZone());
      }
    }
  }