2 * Copyright © 2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.sdc.workflow.api.types;
18 import static junit.framework.TestCase.assertEquals;
19 import static junit.framework.TestCase.fail;
21 import java.util.Arrays;
22 import org.junit.Test;
23 import org.junit.runner.RunWith;
24 import org.mockito.InjectMocks;
25 import org.onap.sdc.workflow.persistence.types.ParameterEntity;
26 import org.onap.sdc.workflow.persistence.types.WorkflowVersion;
27 import org.onap.sdc.workflow.services.exceptions.VersionValidationException;
28 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
30 @RunWith(SpringJUnit4ClassRunner.class)
31 public class WorkflowVersionValidatorTest {
33 private static final String ITEM1_ID = "item_id_1";
36 private WorkflowVersionValidator versionValidator;
39 public void invalidInputs() {
40 WorkflowVersion workflowVersion = new WorkflowVersion();
41 workflowVersion.setDescription("version description");
42 ParameterEntity input = new ParameterEntity();
43 input.setName("input1");
44 workflowVersion.setInputs(Arrays.asList(input, input));
46 versionValidator.validate(ITEM1_ID, workflowVersion);
47 fail("Should have thrown VersionValidationException but did not!");
49 } catch (VersionValidationException ex) {
50 assertEquals(String.format("Error creating or modifying version for workflow with id %s: %s", ITEM1_ID,
51 "Input name must be unique"), ex.getMessage());
56 public void invalidOtputs(){
57 WorkflowVersion workflowVersion = new WorkflowVersion();
58 workflowVersion.setDescription("version description");
59 ParameterEntity output = new ParameterEntity();
60 output.setName("output1");
61 workflowVersion.setOutputs(Arrays.asList(output, output));
63 versionValidator.validate(ITEM1_ID, workflowVersion);
64 fail("Should have thrown VersionValidationException but did not!");
66 } catch (VersionValidationException ex) {
67 assertEquals(String.format("Error creating or modifying version for workflow with id %s: %s", ITEM1_ID,
68 "Output name must be unique"), ex.getMessage());