Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 2c5432e295b6d4a39b0b83673e489be4c845089c (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
/*******************************************************************************
 * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * CONTRIBUTORS:
 * 		hrr@protos.de (initial contribution)
 * 
 *******************************************************************************/

package org.eclipse.etrice.core.genmodel.fsm.tests

import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.eclipse.etrice.core.RoomStandaloneSetup
import org.eclipse.etrice.core.TestBase
import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician
import org.eclipse.etrice.core.genmodel.fsm.NullDiagnostician
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
import org.eclipse.etrice.core.room.ActorClass
import org.eclipse.etrice.core.room.RoomModel
import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory
import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder

class FsmGenTestBase extends TestBase {

	protected Resource res = null
	protected ActorClass actor
	protected IDiagnostician diagnostician = new NullDiagnostician
	protected extension ExtendedFsmGenBuilder builder
	
	new() {
		val injector = new RoomStandaloneSetup().createInjectorAndDoEMFRegistration()
		builder = injector.getInstance(ExtendedFsmGenBuilderFactory).create(diagnostician)
	}

	protected def getGraphContainer(String roomFile, String actorName) {
		prepare(FSMGenModelTestsActivator.getInstance().getBundle())
		res = getResource(roomFile)
		actor = (res.contents.get(0) as RoomModel).actorClasses.findFirst[name.equals(actorName)]
		builder.createTransformedModel(actor)
	}
	
	protected def save(GraphContainer gc, String fileName) {
		val rs = new ResourceSetImpl
		val uri = URI.createFileURI("./output/" + fileName + ".fsmgen")
		val res = rs.createResource(uri)
		res.contents.add(gc)
		res.save(newHashMap)
	}
}

Back to the top