use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class ZMSUtils method error.
public static RuntimeException error(int code, String msg, String caller) {
LOG.error("Error: {} code: {} message: {}", caller, code, msg);
// emit our metrics if configured. the method will automatically
// return from the caller if caller is null
emitMonmetricError(code, caller);
return new ResourceException(code, new ResourceError().code(code).message(msg));
}
use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class ResourceExceptionTest method testCodeOnly.
@Test
public void testCodeOnly() {
ResourceException exc = new ResourceException(400);
assertEquals(exc.getData().toString(), "{code: 400, message: \"Bad Request\"}");
}
use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testUpdatePolicyInvalidName.
@Test
public void testUpdatePolicyInvalidName() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Policy policy = new Policy().setName("policy1");
Mockito.when(mockResultSet.next()).thenReturn(true);
// return domain id
Mockito.doReturn(5).when(mockResultSet).getInt(1);
try {
jdbcConn.updatePolicy("my-domain", policy);
fail();
} catch (ResourceException ex) {
assertEquals(400, ex.getCode());
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testInsertPolicyInvalidName.
@Test
public void testInsertPolicyInvalidName() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Policy policy = new Policy().setName("policy1");
Mockito.when(mockResultSet.next()).thenReturn(true);
// return domain id
Mockito.doReturn(5).when(mockResultSet).getInt(1);
try {
jdbcConn.insertPolicy("my-domain", policy);
fail();
} catch (ResourceException ex) {
assertEquals(400, ex.getCode());
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.ResourceException in project athenz by yahoo.
the class JDBCConnectionTest method testDeleteQuotaInvalidDomain.
@Test
public void testDeleteQuotaInvalidDomain() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Mockito.when(mockResultSet.next()).thenReturn(false);
try {
jdbcConn.deleteQuota("athenz");
fail();
} catch (ResourceException ex) {
assertEquals(404, ex.getCode());
}
jdbcConn.close();
}
Aggregations