Skip to main content
summaryrefslogtreecommitdiffstats
blob: 769470db71ab9d59347a43810722a5af963a49fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*******************************************************************************
 * Copyright (c) 2017 Thales Global Services S.A.S.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Abel Hegedus (IncQuery Labs Ltd.) - initial API and implementation
 *******************************************************************************/
package org.eclipse.emf.diffmerge.patch.tests.persistence.emf

import java.io.File
import org.eclipse.emf.diffmerge.patch.api.ModelPatch
import org.eclipse.emf.diffmerge.patch.api.ModelPatchException
import org.eclipse.emf.diffmerge.patch.persistence.emf.EMFModelPatchSerializer
import org.junit.Test

import static org.junit.Assert.*

class ModelPatchSerializerEMFTest extends BaseModelPatchPersistenceEMFTest {

  public static val PATCH_FILE_PATH = "../org.eclipse.emf.diffmerge.patch.tests.emf/model/demo-patch-generated."
  public static val RESULT_FILE_PATH = "../org.eclipse.emf.diffmerge.patch.tests.emf/results/demo-patch-generated."

  @Test
  def void persist_emptyModelPatch() throws ModelPatchException {
    val modelPatch = new ModelPatch()
    val emfSerializer = new EMFModelPatchSerializer()
    val eModelPatch = emfSerializer.serialize(modelPatch)
    println(eModelPatch);
    assertTrue(eModelPatch.contains("org.eclipse.emf.diffmerge.patch:EModelPatch"));
  }

  @Test
  def void persist_entries() throws ModelPatchException {
    val modelPatch = buildPatch()
    val emfSerializer = new EMFModelPatchSerializer()
    val eModelPatch = emfSerializer.serialize(modelPatch)
    println(eModelPatch)
    assertTrue(eModelPatch.contains("entries"))
  }

  @Test
  def void load_entries() throws ModelPatchException {
    val modelPatch = buildPatch()
    val emfSerializer = new EMFModelPatchSerializer()
    val eModelPatch = emfSerializer.serialize(modelPatch)

    val modelPatch2 = emfSerializer.load(eModelPatch)
    assertEquals(modelPatch.entries.size, modelPatch2.entries.size)
  }

  @Test
  def void persist_file() throws ModelPatchException {
    val patchFile = new File(PATCH_FILE_PATH + "emodelpatch");
    val epatchFile = new File(RESULT_FILE_PATH + "emodelpatch");
    epatchFile.delete
    val emfSerializer = new EMFModelPatchSerializer()
    val modelPatch = emfSerializer.load(patchFile)
    emfSerializer.serialize(modelPatch,epatchFile)
    assertTrue(epatchFile.exists)
  }

  @Test
  def void load_file() throws ModelPatchException {
    val epatchFile = new File(PATCH_FILE_PATH + "emodelpatch");
    val emfSerializer = new EMFModelPatchSerializer()

    val modelPatch = emfSerializer.load(epatchFile)
    assertTrue(modelPatch.entries.size > 0)
  }
}

Back to the top