| /** |
| ******************************************************************************** |
| * Copyright (c) 2016-2019 Vector Informatik GmbH and others. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Vector Informatik GmbH - initial API and implementation |
| ******************************************************************************** |
| */ |
| package org.eclipse.app4mc.amalthea.validation.ta.tests |
| |
| import java.util.List |
| import java.util.stream.Collectors |
| import org.eclipse.app4mc.amalthea.model.Amalthea |
| import org.eclipse.app4mc.amalthea.model.AmaltheaFactory |
| import org.eclipse.app4mc.amalthea.model.Scenario |
| import org.eclipse.app4mc.amalthea.model.builder.AmaltheaBuilder |
| import org.eclipse.app4mc.amalthea.model.builder.StimuliBuilder |
| import org.eclipse.app4mc.amalthea.validations.ta.TimingArchitectsProfile |
| import org.eclipse.app4mc.validation.core.Severity |
| import org.eclipse.app4mc.validation.core.ValidationDiagnostic |
| import org.eclipse.app4mc.validation.util.ValidationExecutor |
| import org.junit.Test |
| |
| import static org.junit.Assert.assertFalse |
| import static org.junit.Assert.assertTrue |
| |
| class TAStimuliModelValidatorTests { |
| extension AmaltheaBuilder b1 = new AmaltheaBuilder |
| extension StimuliBuilder b2 = new StimuliBuilder |
| val executor = new ValidationExecutor(TimingArchitectsProfile) |
| |
| def List<ValidationDiagnostic> validate(Amalthea model) { |
| executor.validate(model) |
| executor.results |
| } |
| |
| def Scenario createScenario(double samplingRecurrence) { |
| val ret = AmaltheaFactory.eINSTANCE.createScenario |
| ret.samplingRecurrence = samplingRecurrence |
| ret |
| } |
| |
| @Test |
| def void test_TAStimuliVRStimulus() { |
| val model = amalthea [ |
| stimuliModel [ |
| variableRateStimulus [ |
| name = "vrs_ok" |
| scenario = createScenario(2.0) |
| ] |
| variableRateStimulus [ |
| name = "vrs_nos" |
| ] |
| ] |
| ] |
| val validationResult = validate(model) |
| val result = validationResult.stream.filter[it.severityLevel == Severity.ERROR].map[it.message].collect(Collectors.toList) |
| assertTrue(result.contains("Scenario must be set in Variable Rate Stimulus \"vrs_nos\".")) |
| assertFalse(result.contains("Scenario must be set in Variable Rate Stimulus \"vrs_ok\".")) |
| } |
| |
| } |