Search in sources :

Example 56 with Status

use of com.arbindo.mimock.manage.mimocks.models.v1.Status in project geotoolkit by Geomatys.

the class WPS2Process method checkResult.

/**
 * A Function to ensure response object is success or failure. Otherwise, we request continually status until
 * we reach a result.
 *
 * @param response The execute response given by service.
 */
private Result checkResult(Object response) throws IOException, JAXBException, InterruptedException, ProcessException {
    if (response instanceof ExceptionResponse) {
        final ExceptionResponse report = (ExceptionResponse) response;
        throw new ProcessException("Exception when executing the process.", this, report.toException());
    } else if (response instanceof StatusInfo) {
        final StatusInfo statusInfo = (StatusInfo) response;
        Status status = statusInfo.getStatus();
        jobId = statusInfo.getJobID();
        if (Status.SUCCEEDED.equals(status)) {
            fireProgressing("WPS remote process has been successfully executed", 100f, false);
            return null;
        } else if (Status.FAILED.equals(status)) {
            throw new ProcessException("Process failed", this);
        } else if (Status.DISMISS.equals(status)) {
            throw new DismissProcessException("WPS remote process has been canceled", this);
        } else if (Status.ACCEPTED.equals(status)) {
            // Initial status
            fireProgressing("Process accepted: " + jobId, 0, false);
        } else {
            // Running
            final Integer progress = statusInfo.getPercentCompleted();
            // Not in the standard
            String message = statusInfo.getMessage();
            if (message == null || (message = message.trim()).isEmpty()) {
                message = status.name();
            }
            fireProgressing(message, progress == null ? Float.NaN : progress, false);
        }
        // loop until we have an answer
        Object tmpResponse;
        // TODO : make timelapse configurable
        int timeLapse = 3000;
        // we tolerate a few unmarshalling or IO errors, the servers behave differentely
        // and may not offer the result file right from the start
        int failCount = 0;
        while (true) {
            stopIfDismissed();
            synchronized (this) {
                wait(timeLapse);
            }
            try {
                tmpResponse = getStatus();
                failCount = 0;
            } catch (UnmarshalException | IOException ex) {
                if (failCount < 5 && !isDimissed()) {
                    failCount++;
                    continue;
                } else if (isDimissed()) {
                    throw new DismissProcessException("WPS remote process has been canceled", this);
                } else {
                    // happenning so we consider the process failed
                    throw ex;
                }
            }
            if (tmpResponse instanceof StatusInfo) {
                final StatusInfo statInfo = (StatusInfo) tmpResponse;
                status = statInfo.getStatus();
                if (Status.SUCCEEDED.equals(status)) {
                    fireProgressing("WPS remote process has been successfully executed", 100f, false);
                    return null;
                } else if (Status.FAILED.equals(status)) {
                    throw new ProcessException("Process failed", this);
                } else if (Status.DISMISS.equals(status)) {
                    throw new DismissProcessException("WPS remote process has been canceled", this);
                }
                // Not in the standard
                String message = statusInfo.getMessage();
                if (message == null || (message = message.trim()).isEmpty()) {
                    message = status.name();
                }
                final Integer percentCompleted = statInfo.getPercentCompleted();
                if (!Objects.equals(message, lastMessage) || !Objects.equals(percentCompleted, lastProgress)) {
                    lastMessage = message;
                    lastProgress = percentCompleted;
                    fireProgressing(lastMessage, lastProgress, false);
                }
            } else if (tmpResponse instanceof ExceptionResponse) {
                final ExceptionResponse report = (ExceptionResponse) tmpResponse;
                throw new ProcessException("Exception when executing the process.", this, report.toException());
            }
        }
    } else if (response instanceof Result) {
        final Result result = checkLegacyResult((Result) response);
        if (result.getJobID() != null) {
            jobId = result.getJobID();
        }
        return result;
    } else {
        throw new ProcessException("Unexpected response " + response, this);
    }
}
Also used : Status(org.geotoolkit.wps.xml.v200.Status) LegacyStatus(org.geotoolkit.wps.xml.v100.LegacyStatus) ProcessException(org.geotoolkit.process.ProcessException) DismissProcessException(org.geotoolkit.process.DismissProcessException) ExceptionResponse(org.geotoolkit.ows.xml.ExceptionResponse) StatusInfo(org.geotoolkit.wps.xml.v200.StatusInfo) DismissProcessException(org.geotoolkit.process.DismissProcessException) Result(org.geotoolkit.wps.xml.v200.Result)

Example 57 with Status

use of com.arbindo.mimock.manage.mimocks.models.v1.Status in project theta by ftsrg.

the class Z3Solver method check.

@Override
public SolverStatus check() {
    final Status z3Status = z3Solver.check();
    status = transformStatus(z3Status);
    return status;
}
Also used : SolverStatus(hu.bme.mit.theta.solver.SolverStatus) Status(com.microsoft.z3.Status)

Example 58 with Status

use of com.arbindo.mimock.manage.mimocks.models.v1.Status in project yakc by manusa.

the class CustomResourceV1IT method deleteNamespacedMountain.

@Test
@DisplayName("deleteNamespacedMountain, should delete existing Mountain")
void deleteNamespacedMountain() throws IOException {
    // When
    final Status result = KC.create(MountainsV1Api.class).deleteNamespacedMountain(mountainName, NAMESPACE).get();
    // Then
    assertThat(result).isNotNull().hasFieldOrPropertyWithValue("status", "Success");
}
Also used : Status(com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status) CustomResourceDefinitionV1IT.deleteCustomResourceDefinitionForTest(com.marcnuri.yakc.CustomResourceDefinitionV1IT.deleteCustomResourceDefinitionForTest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 59 with Status

use of com.arbindo.mimock.manage.mimocks.models.v1.Status in project yakc by manusa.

the class EventsV1ApiIT method deleteNamespacedEvent.

@Test
@DisplayName("deleteNamespacedEvent, should delete existing Event")
void deleteNamespacedEvent() throws IOException {
    // When
    final Status result = deleteEventForTest();
    // Then
    assertThat(result).isNotNull().extracting(Status::getStatus).isEqualTo("Success");
}
Also used : Status(com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 60 with Status

use of com.arbindo.mimock.manage.mimocks.models.v1.Status in project yakc by manusa.

the class SecretIT method deleteNamespacedSecret.

@Test
@DisplayName("deleteNamespacedSecret, should delete existing Secret")
void deleteNamespacedSecret() throws IOException {
    // When
    final Status result = KC.create(CoreV1Api.class).deleteNamespacedSecret(secretName, NAMESPACE, DeleteOptions.builder().gracePeriodSeconds(1).build()).get();
    // Then
    assertThat(result).isNotNull().extracting(Status::getStatus).isEqualTo("Success");
}
Also used : Status(com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Status (com.microsoft.z3.Status)63 BoolExpr (com.microsoft.z3.BoolExpr)55 Test (org.junit.Test)49 Test (org.junit.jupiter.api.Test)21 JsonMapper.convertObjectToJsonString (com.arbindo.mimock.helpers.general.JsonMapper.convertObjectToJsonString)13 RandomDataGenerator.generateRandomAlphabeticString (com.arbindo.mimock.helpers.general.RandomDataGenerator.generateRandomAlphabeticString)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)13 MvcResult (org.springframework.test.web.servlet.MvcResult)13 Mock (com.arbindo.mimock.entities.Mock)12 Expr (com.microsoft.z3.Expr)10 IOException (java.io.IOException)10 MockRequest (com.arbindo.mimock.manage.mimocks.models.v1.MockRequest)9 ProcessedMockRequest (com.arbindo.mimock.manage.mimocks.models.v1.ProcessedMockRequest)9 Status (com.arbindo.mimock.manage.mimocks.models.v1.Status)9 Context (com.microsoft.z3.Context)9 Pageable (org.springframework.data.domain.Pageable)9 HttpStatus (org.springframework.http.HttpStatus)9 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)9