cbc: Introduce test TC_create_nack_bsc

Related: OS#4945
Change-Id: Iabeb3e9d86eaf59b76504edf3976a947ae29b911
diff --git a/cbc/BSC_ConnectionHandler.ttcn b/cbc/BSC_ConnectionHandler.ttcn
index 804d246..1878f3e 100644
--- a/cbc/BSC_ConnectionHandler.ttcn
+++ b/cbc/BSC_ConnectionHandler.ttcn
@@ -44,7 +44,8 @@
 	boolean tcp_is_client,
 	void_fn start_fn,
 	CBS_Message exp_cbs_msg optional,
-	BSSMAP_FIELD_CellIdentificationList cell_list_success optional
+	BSSMAP_FIELD_CellIdentificationList cell_list_success optional,
+	CBSP_FailureListItems tx_fail_list optional
 };
 
 function f_BSC_ConnHdlr_main(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
@@ -126,11 +127,12 @@
 
 function f_cbsp_tx_write_fail(CBS_Message msg, integer idx := 0,
 				      template (omit) BSSMAP_FIELD_CellIdentificationList tx_cell_list := omit,
+				      template (omit) CBSP_IE_NumBcastComplList tx_compl_list := omit,
 				      template (omit) CBSP_FailureListItems tx_fail_list := omit)
 runs on BSC_ConnHdlr {
 	var template (value) CBSP_PDU tx;
 	tx := ts_CBSP_WRITE_CBS_FAIL(msg.msg_id, msg.ser_nr, valueof(tx_fail_list),
-				     omit, tx_cell_list, msg.channel_ind);
+				     tx_compl_list, tx_cell_list, msg.channel_ind);
 	CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx));
 }
 
@@ -162,7 +164,7 @@
 		if (istemplatekind(tx_fail_list, "omit")) {
 			f_cbsp_tx_write_compl(msg, idx, tx_cell_list, tx_compl_list);
 		} else {
-			f_cbsp_tx_write_fail(msg, idx, tx_cell_list, tx_fail_list);
+			f_cbsp_tx_write_fail(msg, idx, tx_cell_list, tx_compl_list, tx_fail_list);
 		}
 		}
 	[] as_cbsp_keepalive_ack(idx) { repeat; }
diff --git a/cbc/CBC_Tests.ttcn b/cbc/CBC_Tests.ttcn
index 437ba0b..8daa3bf 100644
--- a/cbc/CBC_Tests.ttcn
+++ b/cbc/CBC_Tests.ttcn
@@ -118,7 +118,8 @@
 		tcp_is_client := tcp_is_client,
 		start_fn := refers(f_BSC_ConnHdlr_start_fn_void),
 		exp_cbs_msg := omit,
-		cell_list_success := omit
+		cell_list_success := omit,
+		tx_fail_list := omit
 	};
 	return pars;
 }
@@ -681,6 +682,41 @@
 	f_shutdown_helper();
 }
 
+/* Test BSC answering WRITE-REPLACE REQUEST with WRITE-REPLACE FAILURE */
+private function f_bsc_TC_create_nack_bsc() runs on BSC_ConnHdlr {
+	f_cbsp_handle_write(g_pars.exp_cbs_msg, 0, g_pars.cell_list_success, g_pars.tx_fail_list);
+}
+testcase TC_create_nack_bsc() runs on test_CT {
+	var template (value) BSSMAP_FIELD_CellIdentificationList cell_list_success;
+	var template (value) CBSP_FailureListItems tx_fail_list;
+	var CBS_Message msg;
+	var EcbeCbcMessage ecbe;
+
+	msg := valueof(t_CBSmsg(49, 16752));
+
+	f_init(num_bsc := 1, num_mme := 0);
+
+	cell_list_success := ts_BSSMAP_CIL_CGI({
+		ts_BSSMAP_CI_CGI('901'H, '70'H, 23, 42),
+		ts_BSSMAP_CI_CGI('901'H, '70'H, 24, 42)
+	});
+	tx_fail_list := {
+		CBSP_FailureListItem_CGI(ts_BSSMAP_CI_CGI('901'H, '70'H, 24, 48), CBSP_CAUSE_CELL_ID_NOT_VALID),
+		CBSP_FailureListItem_LAC_CI(ts_BSSMAP_CI_LAC_CI(10001, 50001), CBSP_CAUSE_LAI_OR_LAC_NPT_VALID)
+	};
+	g_pars_BSC[0].start_fn := refers(f_bsc_TC_create_nack_bsc);
+	g_pars_BSC[0].exp_cbs_msg := msg;
+	g_pars_BSC[0].cell_list_success := valueof(cell_list_success);
+	g_pars_BSC[0].tx_fail_list := valueof(tx_fail_list);
+	f_start();
+
+	ecbe := f_cbs2ecbe(msg, "TTCN-3");
+	f_ecbe_tx_post_cbs(ecbe);
+	f_ecbe_rx_resp(201);
+
+	f_shutdown_helper();
+}
+
 control {
 	execute( TC_rx_keepalive() );
 	execute( TC_rx_keepalive_timeout() );
@@ -698,6 +734,8 @@
 
 	execute( TC_ecbe_create_delete_etws_bsc() );
 	execute( TC_ecbe_create_delete_etws_mme() );
+
+	execute( TC_create_nack_bsc() );
 }
 
 }