summaryrefslogtreecommitdiffstats
path: root/dcaedt_be/src/test/java/org/onap/sdc/dcae/rule/editor/impl/RulesBusinessLogicTest.java
blob: bc03632c6791bd191d046e6feac9c7d047cf1d7c (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
package org.onap.sdc.dcae.rule.editor.impl;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;
import org.onap.sdc.dcae.composition.restmodels.ruleeditor.*;
import org.onap.sdc.dcae.errormng.ErrorConfigurationLoader;
import org.onap.sdc.dcae.errormng.ResponseFormatManager;
import org.onap.sdc.dcae.errormng.ServiceException;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.*;

public class RulesBusinessLogicTest {
	private static Gson gson = new GsonBuilder()
			.registerTypeAdapter(BaseAction.class, new ActionDeserializer())
			.registerTypeAdapter(BaseCondition.class, new ConditionDeserializer()).create();

	@InjectMocks
	private RulesBusinessLogic rulesBusinessLogic = new RulesBusinessLogic();
	private ResponseFormatManager responseFormatManager = null;

	@Before
	public void setup(){
		MockitoAnnotations.initMocks(this);
		ErrorConfigurationLoader errorConfigurationLoader = new ErrorConfigurationLoader(System.getProperty("user.dir")+"/src/main/webapp/WEB-INF");
		responseFormatManager = ResponseFormatManager.getInstance();
	}

	@Test
	public void translateSingleRuleSingleCopyActionAddSnmpHeader() throws Exception {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"snmp_map\",\"processors\":[{\"array\":\"varbinds\",\"datacolumn\":\"varbind_value\",\"keycolumn\":\"varbind_oid\",\"class\":\"SnmpConvertor\"},"
				+ "{\"phase\":\"phase_1\",\"class\":\"RunPhase\"}]},{\"phase\":\"phase_1\",\"processors\":[{\"updates\":{\"event.commonEventHeader.version\":\"2.0\"},\"class\":\"Set\"}]},"
				+ "{\"phase\":\"phase_1\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";

		Rule rule = new Rule();
		rule.setActions(new ArrayList<>());
		rule.getActions().add(buildCopyAction("2.0","event.commonEventHeader.version"));
		rule.setDescription("description");
		MappingRules mr = new MappingRules(rule);
		List<ServiceException> errors = rulesBusinessLogic.validateRules(mr);
		assertTrue(errors.isEmpty());
		assertEquals(expectedTranslation, rulesBusinessLogic.translateRules(mr, "snmp_map", "map_publish", "phase_1"));
	}

	@Test
	public void translateSingleRuleSingleDateFormatterActionSnmpFlow() throws Exception {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"snmp_map\",\"processors\":[{\"array\":\"varbinds\",\"datacolumn\":\"varbind_value\",\"keycolumn\":\"varbind_oid\",\"class\":\"SnmpConvertor\"},"
				+ "{\"phase\":\"phase_1\",\"class\":\"RunPhase\"}]},{\"phase\":\"phase_1\",\"processors\":[{\"fromFormat\":\"fromFormat\",\"fromTz\":\"fromTZ\",\"toField\":\"targetField\",\"toFormat\":\"toFormat\",\"toTz\":\"toTz\",\"value\":\"fromField\",\"class\":\"DateFormatter\"}]},"
				+ "{\"phase\":\"phase_1\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";

		Rule rule = new Rule();
		rule.setActions(new ArrayList<>());
		rule.getActions().add(buildDateFormatterAction());
		rule.setDescription("description");
		MappingRules mr = new MappingRules(rule);
		List<ServiceException> errors = rulesBusinessLogic.validateRules(mr);
		assertTrue(errors.isEmpty());
		assertEquals(expectedTranslation, rulesBusinessLogic.translateRules(mr, "snmp_map", "map_publish", "phase_1"));
	}

	@Test
	public void translateSingleRuleMultipleCopyActionsAddSnmpHeader() throws Exception {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"snmp_map\",\"processors\":[{\"array\":\"varbinds\",\"datacolumn\":\"varbind_value\",\"keycolumn\":\"varbind_oid\",\"class\":\"SnmpConvertor\"},"
				+ "{\"phase\":\"phase_1\",\"class\":\"RunPhase\"}]},{\"phase\":\"phase_1\","
				+ "\"processors\":[{\"updates\":{\"event.commonEventHeader.version\":\"2.0\",\"event.commonEventHeader.eventId\":\"${event.commonEventHeader.sourceName}_${eventGroup}\"},\"class\":\"Set\"},"
				+ "{\"regex\":\"([^:]*):.*\",\"field\":\"targetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"}]},{\"phase\":\"phase_1\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";

		MappingRules mr = new MappingRules(buildRuleWithMultipleCopyActions());
		List<ServiceException> errors = rulesBusinessLogic.validateRules(mr);
		assertTrue(errors.isEmpty());
		assertEquals(expectedTranslation, rulesBusinessLogic.translateRules(mr, "snmp_map", "map_publish", "phase_1"));
	}

	@Test
	public void translateMultipleRulesMultipleCopyActionsAddSnmpHeader() throws Exception {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"snmp_map\",\"processors\":[{\"array\":\"varbinds\",\"datacolumn\":\"varbind_value\",\"keycolumn\":\"varbind_oid\",\"class\":\"SnmpConvertor\"},"
				+ "{\"phase\":\"phase_1\",\"class\":\"RunPhase\"}]},{\"phase\":\"phase_1\","
				+ "\"processors\":[{\"updates\":{\"event.commonEventHeader.version\":\"2.0\",\"event.commonEventHeader.eventId\":\"${event.commonEventHeader.sourceName}_${eventGroup}\"},\"class\":\"Set\"},"
				+ "{\"regex\":\"([^:]*):.*\",\"field\":\"targetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"}]},{\"phase\":\"phase_1\","
				+ "\"processors\":[{\"updates\":{\"event.commonEventHeader.version\":\"2.0\",\"event.commonEventHeader.eventId\":\"${event.commonEventHeader.sourceName}_${eventGroup}\"},\"class\":\"Set\"},"
				+ "{\"regex\":\"([^:]*):.*\",\"field\":\"targetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"}]},{\"phase\":\"phase_1\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";

		MappingRules mr = new MappingRules(buildRuleWithMultipleCopyActions());
		mr.addOrReplaceRule(buildRuleWithMultipleCopyActions());
		assertEquals(expectedTranslation, rulesBusinessLogic.translateRules(mr, "snmp_map", "map_publish", "phase_1"));
	}

	@Test
	public void emptyStringTest() throws Exception {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"snmp_map\",\"processors\":[{\"array\":\"varbinds\",\"datacolumn\":\"varbind_value\",\"keycolumn\":\"varbind_oid\",\"class\":\"SnmpConvertor\"},"
				+ "{\"phase\":\"phase_1\",\"class\":\"RunPhase\"}]},{\"phase\":\"phase_1\",\"processors\":[{\"map\":{\"\":\"\"},\"field\":\"\",\"toField\":\"mapTargetField\",\"default\":\"\",\"class\":\"MapAlarmValues\"}]},"
				+ "{\"phase\":\"phase_1\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";
		String ruleRequestBody = "{version:4.1,eventType:syslogFields,description:description,actions:[{actionType:map,from:{value:'\"\"'},target:mapTargetField,map:{values:[{key:'\"\"',value:'\"\"'}],haveDefault:true,default:'\"\"'}}]}";
		Rule myRule = gson.fromJson(ruleRequestBody, Rule.class);
		MappingRules mr = new MappingRules(myRule);
		List<ServiceException> errors = rulesBusinessLogic.validateRules(mr);
		assertTrue(errors.isEmpty());
		assertEquals(expectedTranslation, rulesBusinessLogic.translateRules(mr, "snmp_map", "map_publish", "phase_1"));
	}

	@Test
	public void singleStringConditionTranslationTest() throws Exception {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"syslog_map\",\"processors\":[{\"phase\":\"phase_1\",\"class\":\"RunPhase\"}]},{\"phase\":\"phase_1\",\"filter\":{\"string\":\"left\",\"value\":\"right\",\"class\":\"Contains\"},"
				+ "\"processors\":[{\"updates\":{\"event.commonEventHeader.version\":\"2.0\",\"event.commonEventHeader.eventId\":\"${event.commonEventHeader.sourceName}_${eventGroup}\"},\"class\":\"Set\"},"
				+ "{\"regex\":\"([^:]*):.*\",\"field\":\"targetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"}]},{\"phase\":\"phase_1\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";
		String input = "{operator:contains,left:left,right:[right]}";
		Rule rule = buildRuleWithMultipleCopyActions();
		rule.setCondition(gson.fromJson(input, BaseCondition.class));
		MappingRules mr = new MappingRules(rule);
		assertEquals(expectedTranslation, rulesBusinessLogic.translateRules(mr, "syslog_map", "map_publish", "phase_1"));
	}

	@Test
	public void multiStringConditionTranslationTest() throws Exception {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"foi_map\",\"processors\":[{\"phase\":\"phase_1\",\"class\":\"RunPhase\"}]},"
				+ "{\"phase\":\"phase_1\",\"filter\":{\"filters\":[{\"string\":\"left\",\"value\":\"right1\",\"class\":\"Contains\"},{\"string\":\"left\",\"value\":\"right2\",\"class\":\"Contains\"}],\"class\":\"Or\"},"
				+ "\"processors\":[{\"updates\":{\"event.commonEventHeader.version\":\"2.0\",\"event.commonEventHeader.eventId\":\"${event.commonEventHeader.sourceName}_${eventGroup}\"},\"class\":\"Set\"},"
				+ "{\"regex\":\"([^:]*):.*\",\"field\":\"targetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"}]},{\"phase\":\"phase_1\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";
		String input = "{operator:contains,left:left,right:[right1, right2]}";
		Rule rule = buildRuleWithMultipleCopyActions();
		rule.setCondition(gson.fromJson(input, BaseCondition.class));
		MappingRules mr = new MappingRules(rule);
		assertEquals(expectedTranslation, rulesBusinessLogic.translateRules(mr, "foi_map", "map_publish", "phase_1"));
	}

	@Test
	public void singleFieldConditionTranslationTest() throws Exception {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"snmp_map\",\"processors\":[{\"array\":\"varbinds\",\"datacolumn\":\"varbind_value\",\"keycolumn\":\"varbind_oid\",\"class\":\"SnmpConvertor\"},"
				+ "{\"phase\":\"phase_1\",\"class\":\"RunPhase\"}]},{\"phase\":\"phase_1\",\"filter\":{\"field\":\"left\",\"value\":\"right\",\"class\":\"Equals\"},"
				+ "\"processors\":[{\"updates\":{\"event.commonEventHeader.version\":\"2.0\",\"event.commonEventHeader.eventId\":\"${event.commonEventHeader.sourceName}_${eventGroup}\"},\"class\":\"Set\"},"
				+ "{\"regex\":\"([^:]*):.*\",\"field\":\"targetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"}]},{\"phase\":\"phase_1\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";
		String input = "{operator:equals,left:left,right:[right]}";
		Rule rule = buildRuleWithMultipleCopyActions();
		rule.setCondition(gson.fromJson(input, BaseCondition.class));
		MappingRules mr = new MappingRules(rule);
		assertEquals(expectedTranslation, rulesBusinessLogic.translateRules(mr, "snmp_map", "map_publish", "phase_1"));
	}

	@Test
	public void multiFieldConditionTranslationTest() throws Exception {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"snmp_map\",\"processors\":[{\"array\":\"varbinds\",\"datacolumn\":\"varbind_value\",\"keycolumn\":\"varbind_oid\",\"class\":\"SnmpConvertor\"},"
				+ "{\"phase\":\"phase_1\",\"class\":\"RunPhase\"}]},{\"phase\":\"phase_1\",\"filter\":{\"field\":\"left\",\"values\":[\"right1\",\"right2\"],\"class\":\"NotOneOf\"},"
				+ "\"processors\":[{\"updates\":{\"event.commonEventHeader.version\":\"2.0\",\"event.commonEventHeader.eventId\":\"${event.commonEventHeader.sourceName}_${eventGroup}\"},\"class\":\"Set\"},"
				+ "{\"regex\":\"([^:]*):.*\",\"field\":\"targetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"}]},{\"phase\":\"phase_1\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";
		String input = "{operator:notequal,left:left,right:[right1,right2]}";
		Rule rule = buildRuleWithMultipleCopyActions();
		rule.setCondition(gson.fromJson(input, BaseCondition.class));
		MappingRules mr = new MappingRules(rule);
		assertEquals(expectedTranslation, rulesBusinessLogic.translateRules(mr, "snmp_map", "map_publish", "phase_1"));
	}

	@Test
	public void reorderRuleActionsDuringValidationSuccessTest() {
		Rule rule1 = buildValidRuleWithDependentActions();
		Rule rule2 = buildValidRuleWithDependentActions();
		assertEquals(rule1, rule2);
		List<ServiceException> errors = rulesBusinessLogic.validateRule(rule1);
		assertTrue(errors.isEmpty());
		assertNotEquals(rule1, rule2);
		//after validation actions are reordered: 1, 3, 4, 2, 5
		rule2.getActions().add(1, rule2.getActions().get(2)); // 1, 2, 3, 4, 5 -> 1, 3, 2, 3, 4, 5
		rule2.getActions().remove(3); // 1, 3, 2, 3, 4, 5 -> 1, 3, 2, 4, 5
		rule2.getActions().add(2, rule2.getActions().get(3)); // 1, 3, 2, 4, 5 -> 1, 3, 4, 2, 4, 5
		rule2.getActions().remove(4); // 1, 3, 4, 2, 4, 5 -> 1, 3, 4, 2, 5
		assertEquals(rule1, rule2);
	}

	@Test
	public void reorderRuleActionsDuringValidationFailureTest() {
		String expectedError = "A circular dependency was detected between actions. The following fields should be resolved: event.commonEventHeader.eventId, event.commonEventHeader.sourceName, invalidSelfDependency, circularDependencyTarget_3";
		Rule rule1 = buildRuleWithCircularActionDependencies();
		List<ServiceException> errors = rulesBusinessLogic.validateRule(rule1);
		assertEquals(expectedError, errors.get(0).getFormattedErrorMessage());
	}


	@Test
	public void reorderMappingRulesByDependencySuccessTest() {
		MappingRules mr = new MappingRules(buildRuleWithMultipleCopyActions());
		Rule rule = new Rule();
		rule.setDescription("description");
		rule.setActions(new ArrayList<>());
		// create a dependency between rules
		rule.getActions().add(buildCopyAction("${event.commonEventHeader.someField}","event.commonEventHeader.sourceName"));
		mr.addOrReplaceRule(rule);
		List<String> ruleUids = new ArrayList<>(mr.getRules().keySet());
		String translateBefore = rulesBusinessLogic.translateRules(mr,"snmp_map", "map_publish", "phase_1");
		List<ServiceException> errors = rulesBusinessLogic.validateRules(mr);
		assertTrue(errors.isEmpty());
		List<String> ruleUidsMod = new ArrayList<>(mr.getRules().keySet());
		assertEquals(ruleUids.get(0), ruleUidsMod.get(1));
		assertEquals(ruleUids.get(1), ruleUidsMod.get(0));
		assertNotEquals(translateBefore,  rulesBusinessLogic.translateRules(mr,"snmp_map", "map_publish", "phase_1"));
	}

	@Test
	public void missingLogTextFailureTest() {
		Rule rule = new Rule();
		rule.setDescription("description");
		rule.setActions(new ArrayList<>());
		rule.getActions().add(buildLogTextMissingTextAction());
		List<ServiceException> errors = rulesBusinessLogic.validateRule(rule);
		String expectedError = "Please fill the text field of Log Text action to ";
		assertEquals(expectedError, errors.get(0).getFormattedErrorMessage());
	}

	@Test
	public void reorderMappingRulesCircularDependencyFailureTest() {

		MappingRules mr = new MappingRules(buildRuleWithMultipleCopyActions());
		List<ServiceException> errors = rulesBusinessLogic.validateRules(mr);
		assertTrue(errors.isEmpty());
		Rule rule = new Rule();
		rule.setDescription("description");
		rule.setActions(new ArrayList<>());
		// create a circular dependency between rules
		rule.getActions().add(buildCopyAction("${event.commonEventHeader.version}","event.commonEventHeader.sourceName"));
		String input = "{operator:equals,left:\"${event.commonEventHeader.version}\",right:[\"${event.commonEventHeader.eventId}\"]}";
		rule.setCondition(gson.fromJson(input, BaseCondition.class));
		assertTrue(rulesBusinessLogic.addOrEditRule(mr, rule));
		errors = rulesBusinessLogic.validateRules(mr);
		assertFalse(errors.isEmpty());
		String expectedError = String.format("A circular dependency was detected between rules: %s, %s within fields: event.commonEventHeader.sourceName, event.commonEventHeader.version, event.commonEventHeader.eventId", mr.getRules().keySet().toArray());
		assertEquals(expectedError, errors.get(0).getFormattedErrorMessage());
	}


	@Test
	public void translateNestedComplexConditionSuccessTest() {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"foi_map\",\"processors\":[{\"phase\":\"phase_1\",\"class\":\"RunPhase\"}]},"
				+ "{\"phase\":\"phase_1\",\"filter\":{\"filters\":[{\"field\":\"${event.commonEventHeader.version}\",\"value\":\"${event.commonEventHeader.eventId}\",\"class\":\"Equals\"},"
				+ "{\"filters\":[{\"field\":\"left\",\"value\":\"right\",\"class\":\"NotEqual\"},{\"string\":\"${XXX}\",\"value\":\"right1\",\"class\":\"Contains\"},"
				+ "{\"string\":\"${XXX}\",\"value\":\"right2\",\"class\":\"Contains\"}],\"class\":\"Or\"}],\"class\":\"And\"},"
				+ "\"processors\":[{\"updates\":{\"event.commonEventHeader.version\":\"2.0\"},\"class\":\"Set\"}]},{\"phase\":\"phase_1\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";

		Rule rule = new Rule();
		rule.setActions(new ArrayList<>());
		rule.getActions().add(buildCopyAction("2.0","event.commonEventHeader.version"));
		rule.setDescription("description");
		String condition = "{type:All,children:[{operator:equals,left:\"${event.commonEventHeader.version}\",right:[\"${event.commonEventHeader.eventId}\"]},"
				+ "{type:Any,children:[{operator:contains,left:\"${XXX}\",right:[right1,right2]},{operator:notEqual,left:left,right:[right]}]}]}";
		rule.setCondition(gson.fromJson(condition, BaseCondition.class));
		List<ServiceException> errors = rulesBusinessLogic.validateRule(rule);
		assertTrue(errors.isEmpty());
		assertEquals(expectedTranslation, rulesBusinessLogic.translateRules(new MappingRules(rule),"foi_map", "map_publish", "phase_1"));
	}

	private Rule buildRuleWithMultipleCopyActions() {
		Rule rule = new Rule();
		rule.setDescription("description");
		List<BaseAction> actions = new ArrayList<>();
		actions.add(buildCopyAction("2.0","event.commonEventHeader.version"));
		actions.add(buildConcatAction(Arrays.asList("${event.commonEventHeader.sourceName}","_","${eventGroup}"), "event.commonEventHeader.eventId"));
		actions.add(buildRegexAction("extractFromHere", "targetField", "([^:]*):.*"));
		rule.setActions(actions);
		return rule;
	}

	private Rule buildValidRuleWithDependentActions() {
		Rule rule = buildRuleWithMultipleCopyActions();
		rule.getActions().add(buildConcatAction(Arrays.asList("${targetField}","_","${circularDependencyTarget_3}"), "event.commonEventHeader.sourceName"));
		rule.getActions().add(buildConcatAction(Arrays.asList("${validSelfDependency}","_","${event.commonEventHeader.version}"), "validSelfDependency"));
		return rule;
	}

	private Rule buildRuleWithCircularActionDependencies() {
		Rule rule = buildValidRuleWithDependentActions();
		rule.getActions().add(buildCopyAction("${invalidSelfDependency}", "invalidSelfDependency"));
		rule.getActions().add(buildCopyAction("${event.commonEventHeader.eventId}", "circularDependencyTarget_3"));
		return rule;
	}

	private BaseCopyAction buildCopyAction(String from, String to) {
		BaseCopyAction action = new BaseCopyAction();
		action.setActionType("copy");
		action.setFrom(from);
		action.setTarget(to);
		return action;
	}

	private LogTextAction buildLogTextMissingTextAction(){
		LogTextAction logTextAction = new LogTextAction();
		logTextAction.setActionType("Log Text");
		logTextAction.setLogText("a name", "a level", "");
		return logTextAction;
	}

	private BaseCopyAction buildConcatAction(List<String> from, String to) {
		BaseCopyAction action = new BaseCopyAction();
		action.setActionType("concat");
		action.setFrom(from);
		action.setTarget(to);
		return action;
	}

	private BaseCopyAction buildRegexAction(String from, String to, String regex) {
		BaseCopyAction action = new BaseCopyAction();
		action.setActionType("copy");
		action.setFrom(from, regex);
		action.setTarget(to);
		return action;
	}

	private DateFormatterAction buildDateFormatterAction() {
		DateFormatterAction action = new DateFormatterAction();
		action.setActionType("date formatter");
		action.setFrom("fromField");
		action.setTarget("targetField");
		action.setFromFormat("fromFormat");
		action.setToFormat("toFormat");
		action.setFromTz("fromTZ");
		action.setToTz("toTz");
		return action;
	}
}