use of org.eclipse.emfcloud.modelserver.common.codecs.XmiCodec in project emfcloud-modelserver by eclipse-emfcloud.
the class DefaultModelControllerTest method getAllXmiFormat.
@Test
public void getAllXmiFormat() throws EncodingException, IOException {
final AtomicReference<JsonNode> response = new AtomicReference<>();
final EClass brewingUnit = EcoreFactory.eINSTANCE.createEClass();
Answer<Void> answer = invocation -> {
response.set(invocation.getArgument(0));
return null;
};
doAnswer(answer).when(context).json(any(JsonNode.class));
final LinkedHashMap<String, List<String>> queryParams = new LinkedHashMap<>();
queryParams.put(ModelServerPathParametersV1.FORMAT, Collections.singletonList(ModelServerPathParametersV1.FORMAT_XMI));
when(context.queryParamMap()).thenReturn(queryParams);
final Map<URI, EObject> allModels = Collections.singletonMap(URI.createURI("test"), brewingUnit);
when(modelRepository.getAllModels()).thenReturn(allModels);
modelController.getAll(context);
assertThat(response.get().get(JsonResponseMember.DATA), is(equalTo(Json.object(Json.prop("test", new XmiCodec().encode(brewingUnit))))));
}
use of org.eclipse.emfcloud.modelserver.common.codecs.XmiCodec in project emfcloud-modelserver by eclipse-emfcloud.
the class ModelServerClientV2Test method getElementByNameXMI.
@Test
@SuppressWarnings({ "checkstyle:ThrowsCount" })
public void getElementByNameXMI() throws ExecutionException, InterruptedException, EncodingException, MalformedURLException {
final EClass eClass = EcoreFactory.eINSTANCE.createEClass();
String getElementByNameXMIUrl = baseHttpUrlBuilder.addPathSegment(ModelServerPathsV2.MODEL_ELEMENT).addQueryParameter(ModelServerPathParametersV2.MODEL_URI, "SuperBrewer3000.json").addQueryParameter(ModelServerPathParametersV2.ELEMENT_NAME, "Simple Workflow").addQueryParameter(ModelServerPathParametersV2.FORMAT, ModelServerPathParametersV2.FORMAT_XMI).build().toString();
interceptor.addRule().get().url(getElementByNameXMIUrl).respond(JsonResponse.success(new XmiCodec().encode(eClass)).toString());
ModelServerClientV2 client = createClient();
final CompletableFuture<Response<EObject>> f = client.getModelElementByName("SuperBrewer3000.json", "Simple Workflow", ModelServerPathParametersV2.FORMAT_XMI);
assertTrue(EcoreUtil.equals(f.get().body(), eClass));
}
use of org.eclipse.emfcloud.modelserver.common.codecs.XmiCodec in project emfcloud-modelserver by eclipse-emfcloud.
the class ModelServerClientV2Test method getElementByIdXMI.
@Test
@SuppressWarnings({ "checkstyle:ThrowsCount" })
public void getElementByIdXMI() throws ExecutionException, InterruptedException, EncodingException, MalformedURLException {
final EClass eClass = EcoreFactory.eINSTANCE.createEClass();
String getElementByIdXMIUrl = baseHttpUrlBuilder.addPathSegment(ModelServerPathsV2.MODEL_ELEMENT).addQueryParameter(ModelServerPathParametersV2.MODEL_URI, "SuperBrewer3000.json").addQueryParameter(ModelServerPathParametersV2.ELEMENT_ID, "//@workflows.0").addQueryParameter(ModelServerPathParametersV2.FORMAT, ModelServerPathParametersV2.FORMAT_XMI).build().toString();
interceptor.addRule().get().url(getElementByIdXMIUrl).respond(JsonResponse.success(new XmiCodec().encode(eClass)).toString());
ModelServerClientV2 client = createClient();
final CompletableFuture<Response<EObject>> f = client.getModelElementById("SuperBrewer3000.json", "//@workflows.0", ModelServerPathParametersV2.FORMAT_XMI);
assertTrue(EcoreUtil.equals(f.get().body(), eClass));
}
use of org.eclipse.emfcloud.modelserver.common.codecs.XmiCodec in project emfcloud-modelserver by eclipse-emfcloud.
the class ModelServerClientTest method getXmi.
@Test
@SuppressWarnings({ "checkstyle:ThrowsCount" })
public void getXmi() throws ExecutionException, InterruptedException, EncodingException, MalformedURLException {
final EClass eClass = EcoreFactory.eINSTANCE.createEClass();
String getXmiUrl = baseHttpUrlBuilder.addPathSegment(ModelServerPathsV2.MODEL_BASE_PATH).addQueryParameter(ModelServerPathParametersV2.MODEL_URI, "SuperBrewer3000.json").addQueryParameter(ModelServerPathParametersV2.FORMAT, ModelServerPathParametersV2.FORMAT_XMI).build().toString();
interceptor.addRule().get().url(getXmiUrl).respond(JsonResponse.success(new XmiCodec().encode(eClass)).toString());
ModelServerClient client = createClient();
final CompletableFuture<Response<EObject>> f = client.get("SuperBrewer3000.json", ModelServerPathParametersV2.FORMAT_XMI);
assertTrue(EcoreUtil.equals(f.get().body(), eClass));
}
use of org.eclipse.emfcloud.modelserver.common.codecs.XmiCodec in project emfcloud-modelserver by eclipse-emfcloud.
the class ModelServerClientTest method getElementByNameXMI.
@Test
@SuppressWarnings({ "checkstyle:ThrowsCount" })
public void getElementByNameXMI() throws ExecutionException, InterruptedException, EncodingException, MalformedURLException {
final EClass eClass = EcoreFactory.eINSTANCE.createEClass();
String getElementByNameXMIUrl = baseHttpUrlBuilder.addPathSegment(ModelServerPathsV2.MODEL_ELEMENT).addQueryParameter(ModelServerPathParametersV2.MODEL_URI, "SuperBrewer3000.json").addQueryParameter(ModelServerPathParametersV2.ELEMENT_NAME, "Simple Workflow").addQueryParameter(ModelServerPathParametersV2.FORMAT, ModelServerPathParametersV2.FORMAT_XMI).build().toString();
interceptor.addRule().get().url(getElementByNameXMIUrl).respond(JsonResponse.success(new XmiCodec().encode(eClass)).toString());
ModelServerClient client = createClient();
final CompletableFuture<Response<EObject>> f = client.getModelElementByName("SuperBrewer3000.json", "Simple Workflow", ModelServerPathParametersV2.FORMAT_XMI);
assertTrue(EcoreUtil.equals(f.get().body(), eClass));
}
Aggregations