Search in sources :

Example 96 with Location

use of com.walmartlabs.concord.runtime.v2.model.Location in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleApiClientAppEngineAdminServiceTest method testGetAllAppEngineLocations_success.

@Test
public void testGetAllAppEngineLocations_success() throws IOException, GoogleApiException {
    String pageToken = "page-token";
    ListLocationsResponse response1 = new ListLocationsResponse();
    List<Location> locationsPage1 = Arrays.asList(createMockLocation("location-1"), createMockLocation("location-2"));
    response1.setLocations(locationsPage1);
    response1.setNextPageToken(pageToken);
    List<Location> locationsPage2 = Arrays.asList(createMockLocation("location-3"), createMockLocation("location-4"));
    ListLocationsResponse response2 = new ListLocationsResponse();
    response2.setLocations(locationsPage2);
    response2.setNextPageToken(null);
    when(appengineClientMock.getAppsLocationsListQuery().setPageToken(any())).thenReturn(appengineClientMock.getAppsLocationsListQuery());
    when(appengineClientMock.getAppsLocationsListQuery().execute()).thenReturn(response1);
    Appengine.Apps.Locations.List appsLocationsListQuery2 = mock(Appengine.Apps.Locations.List.class);
    when(appengineClientMock.getAppsLocationsListQuery().setPageToken(eq(pageToken))).thenReturn(appsLocationsListQuery2);
    when(appsLocationsListQuery2.execute()).thenReturn(response2);
    List<Location> expectedResults = new ArrayList<>(locationsPage1);
    expectedResults.addAll(locationsPage2);
    // make the call twice. the service should only be hit once per page
    assertEquals(expectedResults, service.getAllAppEngineLocations(mock(Credential.class)));
    assertEquals(expectedResults, service.getAllAppEngineLocations(mock(Credential.class)));
    verify(appengineClientMock.getAppsLocationsListQuery(), times(1)).execute();
    verify(appsLocationsListQuery2, times(1)).execute();
}
Also used : ListLocationsResponse(com.google.api.services.appengine.v1.model.ListLocationsResponse) Appengine(com.google.api.services.appengine.v1.Appengine) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Location(com.google.api.services.appengine.v1.model.Location) Test(org.junit.Test)

Example 97 with Location

use of com.walmartlabs.concord.runtime.v2.model.Location in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleApiClientAppEngineAdminServiceTest method createMockLocation.

private Location createMockLocation(String id) {
    Location location = new Location();
    location.setLocationId(id);
    return location;
}
Also used : Location(com.google.api.services.appengine.v1.model.Location)

Example 98 with Location

use of com.walmartlabs.concord.runtime.v2.model.Location in project concord by walmartlabs.

the class EventRecordingExecutionListener method afterCommand.

@Override
public Result afterCommand(Runtime runtime, VM vm, State state, ThreadId threadId, Command cmd) {
    if (!eventConfiguration.recordEvents()) {
        return Result.CONTINUE;
    }
    if (!(cmd instanceof StepCommand)) {
        return Result.CONTINUE;
    }
    StepCommand<?> s = (StepCommand<?>) cmd;
    if (s.getStep() instanceof TaskCall || s.getStep() instanceof Expression) {
        return Result.CONTINUE;
    }
    ProcessDefinition pd = runtime.getService(ProcessDefinition.class);
    Location loc = s.getStep().getLocation();
    Map<String, Object> m = new HashMap<>();
    m.put("processDefinitionId", ProcessDefinitionUtils.getCurrentFlowName(pd, s.getStep()));
    m.put("fileName", loc.fileName());
    m.put("line", loc.lineNum());
    m.put("column", loc.column());
    m.put("description", getDescription(s.getStep()));
    m.put("correlationId", s.getCorrelationId());
    ProcessEventRequest req = new ProcessEventRequest();
    // TODO constants
    req.setEventType("ELEMENT");
    req.setData(m);
    req.setEventDate(Instant.now().atOffset(ZoneOffset.UTC));
    try {
        eventsApi.event(processInstanceId.getValue(), req);
    } catch (ApiException e) {
        log.warn("afterCommand [{}] -> error while sending an event to the server: {}", cmd, e.getMessage());
    }
    return Result.CONTINUE;
}
Also used : StepCommand(com.walmartlabs.concord.runtime.v2.runner.vm.StepCommand) ProcessEventRequest(com.walmartlabs.concord.client.ProcessEventRequest) HashMap(java.util.HashMap) ApiException(com.walmartlabs.concord.ApiException)

Example 99 with Location

use of com.walmartlabs.concord.runtime.v2.model.Location in project concord by walmartlabs.

the class TaskCallEventRecordingListener method event.

private static Map<String, Object> event(TaskCallEvent event) {
    Map<String, Object> m = new HashMap<>();
    Step currentStep = event.currentStep();
    m.put("processDefinitionId", ProcessDefinitionUtils.getCurrentFlowName(event.processDefinition(), currentStep));
    Location loc = currentStep != null ? currentStep.getLocation() : null;
    if (loc != null) {
        m.put("fileName", currentStep.getLocation().fileName());
        m.put("line", currentStep.getLocation().lineNum());
        m.put("column", currentStep.getLocation().column());
    }
    String taskName = event.taskName();
    m.put("description", "Task: " + taskName);
    m.put("name", taskName);
    m.put("correlationId", event.correlationId());
    if (event.error() != null) {
        m.put("error", event.error());
    }
    return m;
}
Also used : Step(com.walmartlabs.concord.runtime.v2.model.Step) Location(com.walmartlabs.concord.runtime.v2.model.Location)

Example 100 with Location

use of com.walmartlabs.concord.runtime.v2.model.Location in project concord by walmartlabs.

the class YamlDeserializersV2 method toException.

private static YamlProcessingException toException(Result.Failure<Atom, ?> f, JsonParser p, List<Atom> atoms) {
    Location loc = null;
    String got = "n/a";
    int pos = f.getPosition();
    if (pos >= 0) {
        Atom a = atoms.get(f.getPosition());
        loc = a.location;
        got = a.name;
    }
    return new YamlProcessingException(loc, "Expected: " + f.getMessage() + ". Got '" + got + "'");
}
Also used : YamlProcessingException(com.walmartlabs.concord.runtime.v2.exception.YamlProcessingException) Location(com.walmartlabs.concord.runtime.v2.model.Location)

Aggregations

Test (org.junit.Test)120 Location (org.hl7.fhir.r4.model.Location)93 Location (org.hl7.fhir.dstu3.model.Location)66 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)59 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)42 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)30 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)27 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)21 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)20 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)20 StringParam (ca.uhn.fhir.rest.param.StringParam)20 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)16 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)16 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)16 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)16 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)13 Test (org.junit.jupiter.api.Test)13 ArrayList (java.util.ArrayList)11 HashSet (java.util.HashSet)11 TokenParam (ca.uhn.fhir.rest.param.TokenParam)10