summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java
blob: 73b51be13610992845c9794912cc332d57d081bb (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
package com.att.ecomp.dcae.ci.api.tests.ruleEditor;

import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest;
import com.att.ecomp.dcae.ci.entities.rule_editor.SaveRuleError;
import org.onap.sdc.dcae.composition.services.Artifact;
import org.onap.sdc.dcae.composition.vfcmt.Vfcmt;
import com.att.ecomp.dcae.ci.utilities.DcaeRestClient;
import com.att.ecomp.dcae.ci.utilities.Report;
import com.aventstack.extentreports.Status;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonObject;
import org.onap.sdc.dcae.composition.restmodels.ruleeditor.MappingRules;
import org.onap.sdc.dcae.composition.restmodels.ruleeditor.Rule;
import org.openecomp.d2.ci.api.ElementFactory;
import org.openecomp.d2.ci.datatypes.UserRoleEnum;
import org.testng.annotations.Test;
import org.assertj.core.api.SoftAssertions;
import org.openecomp.d2.ci.datatypes.http.RestResponse;

import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.fail;

import java.util.List;

public class RuleEditorControllerTest extends DcaeRestBaseTest {

	private String ruleRequestBody =
			"{version:4.1,eventType:syslogFields,description:newRule,actions:[{from:{value:fromField,regex:\"\"},target:event.commonEventHeader.target,id:id,actionType:copy},"
					+ "{actionType:concat,from:{values:[{value:concat1},{value:_concat2}]},target:concatTargetField},{actionType:copy,from:{value:extractFromHere,regex:\"([^:]*):.*\"},target:regexTargetField},"
					+ "{actionType:map,from:{value:fromField},target:mapTargetField,map:{values:[{key:sourceVal1,value:targetVal1},{key:sourceVal2,value:targetVal2}],haveDefault:true,default:'\"\"'}},"
					+ "{actionType:\"Date Formatter\",id:98908,from:{value:\"${dateFormatterFrom}\"},target:dateFormatterTarget,dateFormatter:{toTimezone:UVW,fromTimezone:XYZ,fromFormat:inputFormat,toFormat:outputFormat}}],"
					+ "condition:{left:\"${leftOperand}\",operator:contains,right:[rightOperand1,rightOperand2]}}";

	@Test
	public void saveNewMappingRulesArtifactSuccessTest() throws Exception {
		Report.log(Status.INFO, "test start");
		Vfcmt vfcmt = createVfcmt();
		RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "n.1.map", "param1", ruleRequestBody);
		JsonObject jsonRes = gson.fromJson(res.getResponse(), JsonObject.class);
		assertThat(jsonRes.get("version").getAsString()).isEqualTo("4.1");
		assertThat(jsonRes.get("eventType").getAsString()).isEqualTo("syslogFields");
		assertThat(jsonRes.get("uid")).isNotNull();
		String expectedArtifactName = "map_n.1.map_param1_MappingRules.json";
		Artifact savedArtifact = fetchVfcmtArtifactMetadataByName(vfcmt.getUuid(), expectedArtifactName);
		assertThat(savedArtifact).isNotNull();
	}

	@Test
	public void translateSnmpMappingRuleWithAllActionTypesSuccessTest() throws Exception {
		String expectedTranslation = "{\"processing\":[{\"phase\":\"snmp_map\",\"processors\":[{\"array\":\"varbinds\",\"datacolumn\":\"varbind_value\",\"keycolumn\":\"varbind_oid\",\"class\":\"SnmpConvertor\"},"
				+ "{\"phase\":\"%s\",\"class\":\"RunPhase\"}]},{\"phase\":\"%s\",\"filter\":{\"filters\":[{\"string\":\"${leftOperand}\",\"value\":\"rightOperand1\",\"class\":\"Contains\"},"
				+ "{\"string\":\"${leftOperand}\",\"value\":\"rightOperand2\",\"class\":\"Contains\"}],\"class\":\"Or\"},"
				+ "\"processors\":[{\"updates\":{\"event.commonEventHeader.target\":\"fromField\",\"concatTargetField\":\"concat1_concat2\"},\"class\":\"Set\"},"
				+ "{\"regex\":\"([^:]*):.*\",\"field\":\"regexTargetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"},"
				+ "{\"map\":{\"sourceVal1\":\"targetVal1\",\"sourceVal2\":\"targetVal2\"},\"field\":\"fromField\",\"toField\":\"mapTargetField\",\"default\":\"\",\"class\":\"MapAlarmValues\"},"
				+ "{\"fromFormat\":\"inputFormat\",\"fromTz\":\"XYZ\",\"toField\":\"dateFormatterTarget\",\"toFormat\":\"outputFormat\",\"toTz\":\"UVW\",\"value\":\"${dateFormatterFrom}\",\"class\":\"DateFormatter\"}]},"
				+ "{\"phase\":\"%s\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}";
		Vfcmt vfcmt = createVfcmt();
		String name = vfcmt.getName();
		saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody);
		RestResponse res = DcaeRestClient.translateRules(vfcmt.getUuid(),"map", "map", "param1", "SNMP");
		Report.log(Status.INFO, "translateRules response= "+res);
		assertThat(res.getStatusCode()).isEqualTo(200);
		assertThat(res.getResponse()).isEqualTo(String.format(expectedTranslation, name, name, name));
	}

	@Test
	public void addNewRuleToExistingArtifact() throws Exception{
		Vfcmt vfcmt = createVfcmt();
		String nid = "n.565663636.0";
		RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", nid, "param1", ruleRequestBody);
		Rule rule1 = gson.fromJson(res.getResponse(), Rule.class);
		res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", nid, "param1", ruleRequestBody);
		Report.log(Status.INFO, "saveRule response= "+res);
		Rule rule2 = gson.fromJson(res.getResponse(), Rule.class);
		RestResponse responseGetRules = DcaeRestClient.getRules(vfcmt.getUuid(),"map", nid, "param1");
		Report.log(Status.INFO, "getRules response= "+responseGetRules);
		MappingRules rules = gson.fromJson(responseGetRules.getResponse(), MappingRules.class);
		Report.log(Status.INFO, "MappingRules="+responseGetRules.getResponse());
		assertThat(rules.getRules()).hasSize(2);
		assertThat(rules.getRules().keySet()).containsOnly(rule1.getUid(), rule2.getUid());
	}

	@Test
	public void editExistingRuleInArtifact() throws Exception{
		Vfcmt vfcmt = createVfcmt();
		String updated = "This is an update";
		RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody);
		Rule rule = gson.fromJson(res.getResponse(), Rule.class);
		Report.log(Status.INFO, "save rule response=%s", res.getResponse());
		res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1");
		Report.log(Status.INFO, "getRules3 response= "+res);
		MappingRules rules = gson.fromJson(res.getResponse(), MappingRules.class);
		Report.log(Status.INFO, "MappingRules1="+res.getResponse());
		assertThat(rules.getRules().get(rule.getUid()).getDescription()).isEqualTo("newRule");
		assertThat(rules.getRules().keySet()).containsOnly(rule.getUid());
		rule.setDescription(updated);
		DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", rule.toJson());
		Report.log(Status.INFO, "saveRule response= "+res);
		res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1");
		Report.log(Status.INFO, "getRules2 response= "+res);
		rules = gson.fromJson(res.getResponse(), MappingRules.class);
		Report.log(Status.INFO, "MappingRules2="+res.getResponse());
		assertThat(rules.getRules()).hasSize(1);
		assertThat(rules.getRules().get(rule.getUid()).getDescription()).isEqualTo(updated);
	}

	@Test
	public void editRuleInArtifactNoSuchIdErrorTest() throws Exception {
		String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6036\",\"text\":\"Error - Failed to save rule. Internal persistence error\",\"variables\":[],\"formattedErrorMessage\":\"Error - Failed to save rule. Internal persistence error\"}},\"notes\":\"\"}";
		Vfcmt vfcmt = createVfcmt();
		RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody);
		Rule rule = gson.fromJson(res.getResponse(), Rule.class);
		Report.log(Status.INFO, "rule="+rule);
		rule.setUid("NoSuchUid");
		res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", rule.toJson());
		Report.log(Status.INFO, "saveRule response= "+res);
		assertThat(res.getStatusCode()).isEqualTo(409);
		assertThat(res.getResponse()).isEqualTo(expectedError);
	}


	@Test
	public void getAllRules() throws Exception{
		Vfcmt vfcmt = createVfcmt();
		RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody);
		String uid1 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString();
		//save two more rules
		res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", ruleRequestBody);
		Report.log(Status.INFO, "saveRule1 response= "+res);
		String uid2 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString();
		res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", ruleRequestBody);
		Report.log(Status.INFO, "saveRule2 response= "+res);
		String uid3 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString();
		res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1");
		Report.log(Status.INFO, "getRules response= "+res);
		JsonObject jsonRes = gson.fromJson(res.getResponse(), JsonObject.class);
		Report.log(Status.INFO, "jsonRes="+jsonRes);
		assertThat(jsonRes.get("schema")).isNotNull();
		MappingRules actualRules = gson.fromJson(res.getResponse(), MappingRules.class);
		Report.log(Status.INFO, "MappingRules="+res.getResponse());
		assertThat(actualRules.getRules()).hasSize(3);
		assertThat(actualRules.getRules().keySet()).containsOnly(uid1, uid2, uid3);
	}


	@Test
	public void deleteRuleSuccessTest() throws Exception{
		Vfcmt vfcmt = createVfcmt();
		//save first rule
		RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody);
		String uid1 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString();
		// save second rule
		res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", ruleRequestBody);
		Report.log(Status.INFO, "saveRule response= "+res);
		String uid2 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString();
		res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1");
		Report.log(Status.INFO, "getRules1 response= "+res);
		MappingRules actualRules = gson.fromJson(res.getResponse(), MappingRules.class);
		Report.log(Status.INFO, "MappingRules1="+res.getResponse());
		// get all rules should return both
		assertThat(actualRules.getRules()).hasSize(2);
		assertThat(actualRules.getRules().keySet()).containsOnly(uid1, uid2);
		// delete a rule
		res = DcaeRestClient.deleteRule(vfcmt.getUuid(),"map", "map", "param1", uid2);
		Report.log(Status.INFO, "deleteRule1 response= "+res);
		assertThat(res.getStatusCode()).isEqualTo(200);
		res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1");
		Report.log(Status.INFO, "getRules2 response= "+res);
		actualRules = gson.fromJson(res.getResponse(), MappingRules.class);
		Report.log(Status.INFO, "MappingRules2="+res.getResponse());
		// get rules should return one rule
		assertThat(actualRules.getRules()).hasSize(1);
		assertThat(actualRules.getRules().keySet()).containsOnly(uid1);
		// delete the last rule - artifact should be deleted
		res = DcaeRestClient.deleteRule(vfcmt.getUuid(),"map", "map", "param1", uid1);
		Report.log(Status.INFO, "deleteRule2 response= "+res);
		assertThat(res.getStatusCode()).isEqualTo(200);
		String expectedArtifactName = "map_map_param1_MappingRules.json";
		Artifact savedArtifact = fetchVfcmtArtifactMetadataByName(vfcmt.getUuid(), expectedArtifactName);
		Report.log(Status.INFO, "savedArtifact= "+savedArtifact);
		assertThat(savedArtifact).isNull();
		// get rules should return empty
		res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1");
		Report.log(Status.INFO, "getRules3 response= "+res);
		assertThat(res.getStatusCode()).isEqualTo(200);
		assertThat(res.getResponse()).isEqualTo("{}");

	}

	@Test
	public void invalidJsonRuleFormatTest() throws Exception{
		String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6035\",\"text\":\"Error - Rule format is invalid: %1.\",\"variables\":[\"java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $\"],\"formattedErrorMessage\":\"Error - Rule format is invalid: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $.\"}},\"notes\":\"\"}";
		RestResponse res = DcaeRestClient.saveRule("someId", "someName", "someNid", "someParam", "gibberish" );
		assertThat(res.getStatusCode()).isEqualTo(400);
		assertThat(res.getResponse()).isEqualTo(expectedError);
	}

	@Test
	public void invalidActionTypeTest() throws Exception {
		String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6035\",\"text\":\"Error - Rule format is invalid: %1.\",\"variables\":[\"Undefined action type: gibberish\"],\"formattedErrorMessage\":\"Error - Rule format is invalid: Undefined action type: gibberish.\"}},\"notes\":\"\"}";
		RestResponse res = DcaeRestClient.saveRule("someId", "someName", "someNid", "someParam", "{actions:[{actionType:gibberish}]}");
		assertThat(res.getStatusCode()).isEqualTo(400);
		assertThat(res.getResponse()).isEqualTo(expectedError);
	}

	@Test
	public void conflictingUsersErrorTest() throws Exception {
		Vfcmt vfcmt = createVfcmt();
		RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}");
		assertThat(res.getStatusCode()).isEqualTo(200);
		//check out by other user then try to save rule by current user
		res = DcaeRestClient.checkoutVfcmt(vfcmt.getUuid(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId());
		assertThat(res.getStatusCode()).isEqualTo(200);
		res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "someParam", ruleRequestBody);
		assertThat(res.getStatusCode()).isEqualTo(403);
	}

	@Test
	public void uploadArtifactSdcErrorTest() throws Exception {
		String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6036\",\"text\":\"Error - Failed to save rule. Internal persistence error\",\"variables\":[],\"formattedErrorMessage\":\"Error - Failed to save rule. Internal persistence error\"}},\"notes\":\"Error: Invalid content.\"}";
		Vfcmt vfcmt = createVfcmt();
		RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}");
		assertThat(res.getStatusCode()).isEqualTo(200);
		// Generated artifact label would be invalid and should fail when submitted to SDC
		res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "()someParam", ruleRequestBody);
		assertThat(res.getStatusCode()).isEqualTo(409);
		assertThat(res.getResponse()).isEqualTo(expectedError);
	}

	@Test
	public void saveMappingRuleNoSuchNidErrorTest() throws Exception {
		String expectedError =  "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6114\",\"text\":\"DCAE component %1 not found in composition\",\"variables\":[\"noSuchComponent\"],\"formattedErrorMessage\":\"DCAE component noSuchComponent not found in composition\"}},\"notes\":\"\"}";
		Vfcmt vfcmt = createVfcmt();
		RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}");
		assertThat(res.getStatusCode()).isEqualTo(200);
		res = DcaeRestClient.saveRule(vfcmt.getUuid(), "noSuchComponent", "noSuchComponent", "someParam", ruleRequestBody);
		assertThat(res.getStatusCode()).isEqualTo(400);
		assertThat(res.getResponse()).isEqualTo(expectedError);
	}


	@Test
	public void deleteRuleNoSuchIdTest() throws Exception {
		String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6115\",\"text\":\"Delete rule failed. Internal persistence error\",\"variables\":[],\"formattedErrorMessage\":\"Delete rule failed. Internal persistence error\"}},\"notes\":\"\"}";
		Vfcmt vfcmt = createVfcmt();
		//save rule
		saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody);
		RestResponse res = DcaeRestClient.deleteRule(vfcmt.getUuid(),"map", "map", "param1", "noSuchRuleId");
		Report.log(Status.INFO, "deleteRule response=%s", res);
		assertThat(res.getStatusCode()).isEqualTo(409);
		assertThat(res.getResponse()).isEqualTo(expectedError);
	}
	
	// After first rule is saved the mappingRules.json artifact is available for get/delete/edit tests
	private RestResponse saveCompositionAndFirstRuleSuccess(Vfcmt vfcmt, String dcaeCompName, String nid, String configParam, String body) throws Exception {
		// generate and save a composition.yml
		Report.log(Status.INFO, "saveCompositionAndFirstRuleSuccess start");
		RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), String.format("{\"nid\":\"%s\"}", nid));
		Report.log(Status.INFO, "saveComposition response=%s", res);
		assertThat(res.getStatusCode()).isEqualTo(200);
		
		res = DcaeRestClient.saveRule(vfcmt.getUuid(), dcaeCompName, nid, configParam, body);
		Report.log(Status.INFO, "saveRule response=%s", res);
		assertThat(res.getStatusCode()).isEqualTo(200);
		return res;
	}


	@Test
	public void saveMappingRuleNegativeTest_BadResponse() throws Exception {
		// arrange
		Report.log(Status.INFO, "Arrangeing test...");
		ObjectMapper mapper = new ObjectMapper();
		String badRuleRequestBody = "{\"version\":\"5.3\",\"eventType\":\"syslogFields\",\"uid\":\"\",\"description\":\"map rules\","
				+ "\"actions\":[{actionType:\"Date Formatter\",from:{value:whatever}},{\"id\":\"22fdded0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"AAA\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"BBB\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"}],\"haveDefault\":true,\"default\":\"\"}},{\"id\":\"2d6fab00-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"DDD\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"}],\"haveDefault\":false,\"default\":\"\"}},{\"id\":\"60bff5a0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"EEE\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"}],\"haveDefault\":false,\"default\":\"\"}},{\"id\":\"75ea0ce0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"FFF\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"GGG\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"},{\"key\":\"\",\"value\":\"\"}],\"haveDefault\":false,\"default\":\"\"}},{\"id\":\"75ea0ce0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"FFF\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"GGG\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"},{\"key\":\"foo\",\"value\":\"not bar\"}],\"haveDefault\":false,\"default\":\"\"}}],\"condition\":null}";
		Vfcmt vfcmt = createVfcmt();
		Report.log(Status.INFO, "Saving composition of a fake cdump...");
		RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}");
		Report.logDebug("saveComposition response", res);
		if (res.getStatusCode() != 200) {
			fail("Unable to arrange test, save composition failed\n" + res.toString());
		}
		// act
		Report.log(Status.INFO, "Executing...");
		Report.logDebug("Request body", badRuleRequestBody);
		RestResponse targetRes = DcaeRestClient.saveRule(vfcmt.getUuid(), "noSuchComponent", "map", "someParam", badRuleRequestBody);
		Report.logDebug("saveRule response", targetRes);
		// assert
		Report.log(Status.INFO, "Asserting...");
		List<String> errors = mapper.readValue(targetRes.getResponse(), SaveRuleError.class).getFormattedErrors(); // parse response
		SoftAssertions.assertSoftly(softly -> {
			softly.assertThat(targetRes.getStatusCode()).isEqualTo(400);
			softly.assertThat(errors).containsExactlyInAnyOrder(
					"Please fill the default value of map action to BBB",
				    "Please fill the from field of map action to DDD",
				    "Please fill the target field of map action to ",
				    "Please fill all key-value pairs of map action to GGG",
				    "Error: Duplication in map keys exists, please modify rule configuration",
					"Please fill the target field of Date Formatter action to null",
					"Please fill the to timezone field of Date Formatter action to null",
					"Please fill the from timezone field of Date Formatter action to null",
					"Please fill the from format field of Date Formatter action to null",
					"Please fill the to format field of Date Formatter action to null"
					);
		});
	}

	@Test
	public void translateInvalidFlowTypeFailureTest() throws Exception {
		String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6116\",\"text\":\"Translation failed. Reason: %s\",\"variables\":[\"%s\"],\"formattedErrorMessage\":\"Translation failed. Reason: %s\"}},\"notes\":\"\"}";
		RestResponse res = DcaeRestClient.translateRules("someId","map", "map", "param1", "noSuchFlowType");
		assertThat(res.getStatusCode()).isEqualTo(400);
		assertThat(res.getResponse()).isEqualTo(String.format(expectedError, "%1", "Flow type noSuchFlowType not found", "Flow type noSuchFlowType not found"));
		res = DcaeRestClient.translateRules("someId","map", "map", "param1", null);
		assertThat(res.getStatusCode()).isEqualTo(400);
		assertThat(res.getResponse()).isEqualTo(String.format(expectedError, "%1", "Flow type null not found", "Flow type null not found"));
	}
}