use of org.ovirt.engine.sdk4.Error in project ovirt-engine-sdk-java by oVirt.
the class SsoUtils method buildSsoUrlBasic.
/**
* Construct SSO URL to obtain token from username and password.
*
* @param url oVirt engine URL
* @return URI to be used to obtain token
*/
public static URI buildSsoUrlBasic(String url) {
try {
URI uri = new URI(url);
URIBuilder uriBuilder = new URIBuilder(String.format("%1$s://%2$s/ovirt-engine/sso/oauth/%3$s", uri.getScheme(), uri.getAuthority(), ENTRY_POINT_TOKEN));
return uriBuilder.build();
} catch (URISyntaxException ex) {
throw new Error("Failed to build SSO authentication URL", ex);
}
}
use of org.ovirt.engine.sdk4.Error in project ovirt-engine-sdk-java by oVirt.
the class VmsServiceTest method testNullObjectForNonExistingID.
/**
* Test we don get null VM object for non-existing VM id.
*/
@Test
public void testNullObjectForNonExistingID() {
boolean raised = false;
VmService vmService = vmsService.vmService("456");
try {
vmService.get().send().vm();
} catch (Error e) {
assertTrue(e.getMessage().contains("404"));
raised = true;
}
assertTrue(raised);
}
use of org.ovirt.engine.sdk4.Error in project ovirt-engine-sdk-java by oVirt.
the class VmsServiceTest method testFaultReaderWithoutAction.
/**
* When the server returns an action containing a fault
* raises an error containing the information of the fault.
*/
@Test
public void testFaultReaderWithoutAction() {
boolean raised = false;
VmService vmService = vmsService.vmService("123");
try {
vmService.start().send();
} catch (Error e) {
assertTrue(e.getMessage().contains("myreason"));
raised = true;
}
assertTrue(raised);
}
use of org.ovirt.engine.sdk4.Error in project openflowplugin by opendaylight.
the class DeviceContextImplTest method testProcessReply2.
@Test
public void testProcessReply2() {
final Xid dummyXid = new Xid(DUMMY_XID);
final Error mockedError = mock(Error.class);
deviceContext.processReply(dummyXid, Lists.newArrayList(mockedError));
verify(messageSpy).spyMessage(any(Class.class), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_FAILURE));
final MultipartReply mockedMultipartReply = mock(MultipartReply.class);
deviceContext.processReply(dummyXid, Lists.newArrayList(mockedMultipartReply));
verify(messageSpy).spyMessage(any(Class.class), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_SUCCESS));
}
use of org.ovirt.engine.sdk4.Error in project openflowplugin by opendaylight.
the class AbstractRequestCallback method onFailure.
@Override
public final void onFailure(@Nonnull final Throwable throwable) {
final RpcResultBuilder<T> builder;
if (null != eventIdentifier) {
EventsTimeCounter.markEnd(eventIdentifier);
}
if (throwable instanceof DeviceRequestFailedException) {
final Error err = ((DeviceRequestFailedException) throwable).getError();
final String errorString = String.format("Device reported error type %s code %s", err.getTypeString(), err.getCodeString());
builder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, errorString, throwable);
spyMessage(StatisticsGroup.TO_SWITCH_SUBMIT_FAILURE);
} else {
builder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
spyMessage(StatisticsGroup.TO_SWITCH_SUBMIT_ERROR);
}
context.setResult(builder.build());
RequestContextUtil.closeRequestContext(context);
}
Aggregations