@Test
public void testGetAthenzDomain() throws Exception {

    
    JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
    // one-domain, 2 roles, 2 members altogether
    // 1 group with 1 member
    // 2 policies, 2 assertions
    // 1 service, 1 public key
    Mockito.when(mockResultSet.next()).thenReturn(true) // domain
        .thenReturn(true).thenReturn(true).thenReturn(false) // 2 roles
        .thenReturn(true).thenReturn(true).thenReturn(false) // 1 member each
        .thenReturn(true).thenReturn(false) // 1 group
        .thenReturn(true).thenReturn(false) // 1 member
        .thenReturn(true).thenReturn(true).thenReturn(false) // 2 policies
        .thenReturn(true).thenReturn(true).thenReturn(false) // 1 assertion each
        .thenReturn(true).thenReturn(false) // 1 service
        .thenReturn(true).thenReturn(false) // 1 public key
        .thenReturn(true).thenReturn(false); // 1 host
    
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_NAME))
        .thenReturn("role1").thenReturn("role2") // role names
        .thenReturn("group1") // group name
        .thenReturn("policy1").thenReturn("policy2") // policy names
        .thenReturn("service1"); // service name
    
    Mockito.when(mockResultSet.getString(1))
        .thenReturn("role1").thenReturn("role2") // role names
        .thenReturn("group1") // group name
        .thenReturn("policy1").thenReturn("policy2") // policy names
        .thenReturn("service1"); // service names 
        
    Mockito.when(mockResultSet.getString(2))
        .thenReturn("user").thenReturn("user") // role member domain names
        .thenReturn("user") // group member domain names
        .thenReturn("host1"); // service host name
    Mockito.when(mockResultSet.getString(3))
        .thenReturn("user1").thenReturn("user2") // role member local names
        .thenReturn("user3"); // group member local names
    Mockito.doReturn(new java.sql.Timestamp(1454358916)).when(mockResultSet).getTimestamp(ZMSConsts.DB_COLUMN_MODIFIED);
    Mockito.doReturn(true).when(mockResultSet).getBoolean(ZMSConsts.DB_COLUMN_ENABLED);
    Mockito.doReturn(false).when(mockResultSet).getBoolean(ZMSConsts.DB_COLUMN_AUDIT_ENABLED);
    Mockito.doReturn("").when(mockResultSet).getString(ZMSConsts.DB_COLUMN_DESCRIPTION);
    Mockito.doReturn("").when(mockResultSet).getString(ZMSConsts.DB_COLUMN_ORG);
    Mockito.doReturn("").when(mockResultSet).getString(ZMSConsts.DB_COLUMN_UUID);
    Mockito.doReturn("").when(mockResultSet).getString(ZMSConsts.DB_COLUMN_TRUST);
    Mockito.doReturn("").when(mockResultSet).getString(ZMSConsts.DB_COLUMN_ACCOUNT);
    Mockito.doReturn(0).when(mockResultSet).getInt(ZMSConsts.DB_COLUMN_PRODUCT_ID);
    Mockito.doReturn(5).when(mockResultSet).getInt(ZMSConsts.DB_COLUMN_DOMAIN_ID);
    Mockito.doReturn("/usr/bin64/athenz").when(mockResultSet).getString(ZMSConsts.DB_COLUMN_EXECUTABLE);
    Mockito.doReturn("users").when(mockResultSet).getString(ZMSConsts.DB_COLUMN_SVC_GROUP);
    Mockito.doReturn("root").when(mockResultSet).getString(ZMSConsts.DB_COLUMN_SVC_USER);
    Mockito.doReturn("http://server.athenzcompany.com").when(mockResultSet).getString(ZMSConsts.DB_COLUMN_PROVIDER_ENDPOINT);
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_ROLE))
        .thenReturn("role1").thenReturn("role2");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_RESOURCE))
        .thenReturn("my-domain:*").thenReturn("my-domain:service.*");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_ACTION))
        .thenReturn("*").thenReturn("read");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_EFFECT))
        .thenReturn("ALLOW").thenReturn("DENY");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_KEY_ID)).thenReturn("zms1.zone1");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_KEY_VALUE)).thenReturn("Value1");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_KEY_VALUE)).thenReturn("Value1");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_SIGN_ALGORITHM)).thenReturn("rsa");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_CERT_DNS_DOMAIN)).thenReturn("");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_APPLICATION_ID)).thenReturn("");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_NOTIFY_ROLES)).thenReturn("");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_USER_AUTHORITY_FILTER)).thenReturn("");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_USER_AUTHORITY_EXPIRATION)).thenReturn("");
    AthenzDomain athenzDomain = jdbcConn.getAthenzDomain("my-domain");
    assertNotNull(athenzDomain);
    assertEquals("my-domain", athenzDomain.getDomain().getName());
    assertEquals(athenzDomain.getDomain().getSignAlgorithm(), "rsa");
    assertEquals(2, athenzDomain.getRoles().size());
    assertEquals(1, athenzDomain.getRoles().get(0).getRoleMembers().size());
    assertEquals(1, athenzDomain.getRoles().get(1).getRoleMembers().size());
    assertEquals(1, athenzDomain.getGroups().size());
    assertEquals(1, athenzDomain.getGroups().get(0).getGroupMembers().size());
    assertEquals(2, athenzDomain.getPolicies().size());
    assertEquals(1, athenzDomain.getPolicies().get(0).getAssertions().size());
    assertEquals(1, athenzDomain.getPolicies().get(1).getAssertions().size());
    assertEquals(1, athenzDomain.getServices().size());
    assertEquals(1, athenzDomain.getServices().get(0).getPublicKeys().size());
    assertEquals("zms1.zone1", athenzDomain.getServices().get(0).getPublicKeys().get(0).getId());
    assertEquals("Value1", athenzDomain.getServices().get(0).getPublicKeys().get(0).getKey());
    assertEquals(1, athenzDomain.getServices().get(0).getHosts().size());
    assertEquals("host1", athenzDomain.getServices().get(0).getHosts().get(0));
    jdbcConn.close();
}