use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testPrepareDomainScanStatementPrefixModifiedZero.
@Test
public void testPrepareDomainScanStatementPrefixModifiedZero() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
jdbcConn.prepareDomainScanStatement("prefix", 0);
Mockito.verify(mockPrepStmt, times(1)).setString(1, "prefix");
Mockito.verify(mockPrepStmt, times(1)).setString(2, "prefiy");
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testUpdatePolicyModTimestampException.
@Test
public void testUpdatePolicyModTimestampException() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Mockito.when(mockPrepStmt.executeUpdate()).thenThrow(new SQLException("failed operation", "state", 1001));
try {
jdbcConn.updatePolicyModTimestamp("my-domain", "policy1");
fail();
} catch (Exception ex) {
assertTrue(true);
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testUpdateEntity.
@Test
public void testUpdateEntity() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Entity entity = new Entity().setName("entity1").setValue(JSON.fromString("{\"value\":1}", Struct.class));
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.updateEntity("my-domain", entity);
assertTrue(requestSuccess);
Mockito.verify(mockPrepStmt, times(1)).setString(1, "my-domain");
Mockito.verify(mockPrepStmt, times(1)).setString(1, "{\"value\":1}");
Mockito.verify(mockPrepStmt, times(1)).setInt(2, 5);
Mockito.verify(mockPrepStmt, times(1)).setString(3, "entity1");
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testCountAssertions.
@Test
public void testCountAssertions() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Mockito.when(mockResultSet.getInt(1)).thenReturn(5).thenReturn(7).thenReturn(// return domain/policy id/count
1);
Mockito.when(mockResultSet.next()).thenReturn(true);
assertEquals(jdbcConn.countAssertions("my-domain", "policy1"), 1);
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testVerifyDomainAccountUniquenessPassNoMatch.
@Test
public void testVerifyDomainAccountUniquenessPassNoMatch() throws Exception {
Mockito.when(mockResultSet.next()).thenReturn(false);
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
jdbcConn.verifyDomainAccountUniqueness("iaas.athenz", "12345", "unitTest");
jdbcConn.close();
}
Aggregations