Exemplo n.º 1
0
 public void testMutlipleOutObjects() throws Exception {
   fContext.setConfigProperty("createTwoObjects", true);
   ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
   assertEquals(Diagnostic.OK, diagnostic.getSeverity());
   assertOutputObject(fOutput);
   assertEquals(2, fOutput.getContents().size());
 }
Exemplo n.º 2
0
  public void testAssertFailed() throws Exception {
    fContext.setConfigProperty("assertFail", Boolean.TRUE); // $NON-NLS-1$
    ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);

    assertEquals(Diagnostic.ERROR, diagnostic.getSeverity());
    assertEquals(ExecutionDiagnostic.FATAL_ASSERTION, diagnostic.getCode());
    assertFalse(diagnostic.getStackTrace().isEmpty());
    assertTrue(fOutput.getContents().isEmpty());
  }
Exemplo n.º 3
0
  private void assertOutputObject(ModelExtent outModel) {
    EPackage result =
        (EPackage)
            EcoreUtil.getObjectByType(outModel.getContents(), EcorePackage.eINSTANCE.getEPackage());
    EPackage input =
        (EPackage)
            EcoreUtil.getObjectByType(fInput.getContents(), EcorePackage.eINSTANCE.getEPackage());
    assertEquals(input.getName() + "_Ecore2Ecore", result.getName());

    assertUnchangedInput();
  }
Exemplo n.º 4
0
  public void testTransformationLoadFailure() throws Exception {
    URI uri =
        URI.createPlatformPluginURI(
            "org.eclipse.m2m.tests.qvt.oml/deployed/callapi/NotExisting.qvto",
            false); //$NON-NLS-1$
    fExecutor = new TransformationExecutor(uri);

    final ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
    assertEquals(Diagnostic.ERROR, diagnostic.getSeverity());
    assertEquals(ExecutionDiagnostic.TRANSFORMATION_LOAD_FAILED, diagnostic.getCode());
    assertUnchangedInput();
    assertTrue(fOutput.getContents().isEmpty());
  }
Exemplo n.º 5
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    URI uri =
        URI.createPlatformPluginURI(
            "org.eclipse.m2m.tests.qvt.oml/deployed/callapi/Ecore2Ecore.qvto",
            false); //$NON-NLS-1$
    fExecutor = new TransformationExecutor(uri);

    fInput = new BasicModelExtent();
    EPackage inObject = EcoreFactory.eINSTANCE.createEPackage();
    inObject.setName("input"); // $NON-NLS-1$
    fInput.add(inObject);

    fInitialInputContents = new ArrayList<EObject>(fInput.getContents());

    fOutput = new BasicModelExtent();
    fContext = new ExecutionContextImpl();

    assertFalse(fInput.getContents().isEmpty());
    assertTrue(fOutput.getContents().isEmpty());
  }
Exemplo n.º 6
0
  public void testCompilationErrors() throws Exception {
    URI uri =
        URI.createPlatformPluginURI(
            "org.eclipse.m2m.tests.qvt.oml/deployed/callapi/CompilationErrors.qvto",
            false); //$NON-NLS-1$
    fExecutor = new TransformationExecutor(uri);

    final ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
    assertEquals(Diagnostic.ERROR, diagnostic.getSeverity());
    assertEquals(ExecutionDiagnostic.VALIDATION, diagnostic.getCode());
    assertFalse(diagnostic.getChildren().isEmpty());
    assertTrue(diagnostic.getChildren().get(0).getMessage().contains("(at:")); // $NON-NLS-1$

    assertUnchangedInput();
    assertTrue(fOutput.getContents().isEmpty());
  }
Exemplo n.º 7
0
  public void testInvokeSuccess() throws Exception {
    final ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
    assertEquals(Diagnostic.OK, diagnostic.getSeverity());
    assertEquals(0, diagnostic.getCode());

    List<?> outContents = fOutput.getContents();
    assertEquals(1, outContents.size());
    assertOutputObject(fOutput);

    // test re-execution
    BasicModelExtent nextOut = new BasicModelExtent();
    fContext = new ExecutionContextImpl();
    ExecutionDiagnostic nextDiagnostic = fExecutor.execute(fContext, fInput, nextOut);

    assertOutputObject(nextOut);
    assertEquals(Diagnostic.OK, nextDiagnostic.getSeverity());
  }
Exemplo n.º 8
0
 private void assertUnchangedInput() {
   // check the input was not changed
   assertEquals(fInitialInputContents, fInput.getContents());
 }