Search in sources :

Example 46 with Policy

use of com.yahoo.athenz.zms.Policy in project athenz by yahoo.

the class JDBCConnectionTest method testInsertPolicy.

@Test
public void testInsertPolicy() throws Exception {
    JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
    Policy policy = new Policy().setName("my-domain:policy.policy1");
    Mockito.doReturn(1).when(mockPrepStmt).executeUpdate();
    Mockito.when(mockResultSet.next()).thenReturn(true);
    // return domain id
    Mockito.doReturn(5).when(mockResultSet).getInt(1);
    boolean requestSuccess = jdbcConn.insertPolicy("my-domain", policy);
    assertTrue(requestSuccess);
    Mockito.verify(mockPrepStmt, times(1)).setString(1, "my-domain");
    Mockito.verify(mockPrepStmt, times(1)).setString(1, "policy1");
    Mockito.verify(mockPrepStmt, times(1)).setInt(2, 5);
    jdbcConn.close();
}
Also used : Policy(com.yahoo.athenz.zms.Policy) JDBCConnection(com.yahoo.athenz.zms.store.jdbc.JDBCConnection) Test(org.testng.annotations.Test)

Aggregations

Policy (com.yahoo.athenz.zms.Policy)46 Assertion (com.yahoo.athenz.zms.Assertion)24 Test (org.testng.annotations.Test)24 Role (com.yahoo.athenz.zms.Role)22 ArrayList (java.util.ArrayList)18 DomainData (com.yahoo.athenz.zms.DomainData)16 RoleMember (com.yahoo.athenz.zms.RoleMember)13 DataCache (com.yahoo.athenz.zts.cache.DataCache)13 SignedDomain (com.yahoo.athenz.zms.SignedDomain)8 JDBCConnection (com.yahoo.athenz.zms.store.jdbc.JDBCConnection)7 HashMap (java.util.HashMap)7 Domain (com.yahoo.athenz.zms.Domain)6 ResourceException (com.yahoo.athenz.zms.ResourceException)4 ServiceIdentity (com.yahoo.athenz.zms.ServiceIdentity)4 SQLException (java.sql.SQLException)4 Principal (com.yahoo.athenz.auth.Principal)3 SimplePrincipal (com.yahoo.athenz.auth.impl.SimplePrincipal)3 Array (com.yahoo.rdl.Array)2 Struct (com.yahoo.rdl.Struct)2 PreparedStatement (java.sql.PreparedStatement)2