Search in sources :

Example 16 with Error

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);
    }
}
Also used : Error(org.ovirt.engine.sdk4.Error) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 17 with Error

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);
}
Also used : VmService(org.ovirt.engine.sdk4.services.VmService) Test(org.junit.Test)

Example 18 with Error

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);
}
Also used : VmService(org.ovirt.engine.sdk4.services.VmService) Test(org.junit.Test)

Example 19 with Error

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));
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) Error(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error) Test(org.junit.Test)

Example 20 with Error

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);
}
Also used : DeviceRequestFailedException(org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException) Error(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Aggregations

Error (org.eclipse.bpmn2.Error)11 Error (org.ovirt.engine.sdk4.Error)11 RootElement (org.eclipse.bpmn2.RootElement)8 Test (org.junit.Test)8 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)7 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)7 Escalation (org.eclipse.bpmn2.Escalation)6 Process (org.eclipse.bpmn2.Process)6 Signal (org.eclipse.bpmn2.Signal)6 SubProcess (org.eclipse.bpmn2.SubProcess)6 URI (java.net.URI)5 ArrayList (java.util.ArrayList)5 Entry (java.util.Map.Entry)5 Error (org.bytedeco.javacpp.FlyCapture2.Error)5 IOException (java.io.IOException)4 Iterator (java.util.Iterator)4 Activity (org.eclipse.bpmn2.Activity)4 CallActivity (org.eclipse.bpmn2.CallActivity)4 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)4 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)4