11/*
2- * (C) Copyright IBM Corp. 2020, 2022 .
2+ * (C) Copyright IBM Corp. 2023 .
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55 * the License. You may obtain a copy of the License at
2020import java .io .InputStream ;
2121import java .util .HashMap ;
2222import java .util .List ;
23- import java .util .Map ;
2423import org .testng .annotations .Test ;
2524
2625/** Unit test class for the CreateDialogNodeOptions model. */
@@ -31,40 +30,31 @@ public class CreateDialogNodeOptionsTest {
3130
3231 @ Test
3332 public void testCreateDialogNodeOptions () throws Throwable {
33+ DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel =
34+ new DialogNodeOutputTextValuesElement .Builder ().text ("testString" ).build ();
35+ assertEquals (dialogNodeOutputTextValuesElementModel .text (), "testString" );
36+
3437 ResponseGenericChannel responseGenericChannelModel =
3538 new ResponseGenericChannel .Builder ().channel ("chat" ).build ();
3639 assertEquals (responseGenericChannelModel .channel (), "chat" );
3740
38- DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo dialogNodeOutputGenericModel =
39- new DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo .Builder ()
40- .responseType ("video " )
41- .source ( "testString" )
42- .title ( "testString " )
43- .description ( "testString " )
41+ DialogNodeOutputGenericDialogNodeOutputResponseTypeText dialogNodeOutputGenericModel =
42+ new DialogNodeOutputGenericDialogNodeOutputResponseTypeText .Builder ()
43+ .responseType ("text " )
44+ .values ( java . util . Arrays . asList ( dialogNodeOutputTextValuesElementModel ) )
45+ .selectionPolicy ( "sequential " )
46+ .delimiter ( " \n " )
4447 .channels (java .util .Arrays .asList (responseGenericChannelModel ))
45- .channelOptions (
46- new java .util .HashMap <String , Object >() {
47- {
48- put ("foo" , "testString" );
49- }
50- })
51- .altText ("testString" )
5248 .build ();
53- assertEquals (dialogNodeOutputGenericModel .responseType (), "video" );
54- assertEquals (dialogNodeOutputGenericModel .source (), "testString" );
55- assertEquals (dialogNodeOutputGenericModel .title (), "testString" );
56- assertEquals (dialogNodeOutputGenericModel .description (), "testString" );
49+ assertEquals (dialogNodeOutputGenericModel .responseType (), "text" );
50+ assertEquals (
51+ dialogNodeOutputGenericModel .values (),
52+ java .util .Arrays .asList (dialogNodeOutputTextValuesElementModel ));
53+ assertEquals (dialogNodeOutputGenericModel .selectionPolicy (), "sequential" );
54+ assertEquals (dialogNodeOutputGenericModel .delimiter (), "\n " );
5755 assertEquals (
5856 dialogNodeOutputGenericModel .channels (),
5957 java .util .Arrays .asList (responseGenericChannelModel ));
60- assertEquals (
61- dialogNodeOutputGenericModel .channelOptions (),
62- new java .util .HashMap <String , Object >() {
63- {
64- put ("foo" , "testString" );
65- }
66- });
67- assertEquals (dialogNodeOutputGenericModel .altText (), "testString" );
6858
6959 DialogNodeOutputModifiers dialogNodeOutputModifiersModel =
7060 new DialogNodeOutputModifiers .Builder ().overwrite (true ).build ();
@@ -74,67 +64,31 @@ public void testCreateDialogNodeOptions() throws Throwable {
7464 new DialogNodeOutput .Builder ()
7565 .generic (java .util .Arrays .asList (dialogNodeOutputGenericModel ))
7666 .integrations (
77- new java .util .HashMap <String , Map <String , Object >>() {
78- {
79- put (
80- "foo" ,
81- new java .util .HashMap <String , Object >() {
82- {
83- put ("foo" , "testString" );
84- }
85- });
86- }
87- })
67+ java .util .Collections .singletonMap (
68+ "foo" , java .util .Collections .singletonMap ("anyKey" , "anyValue" )))
8869 .modifiers (dialogNodeOutputModifiersModel )
8970 .add ("foo" , "testString" )
9071 .build ();
9172 assertEquals (
9273 dialogNodeOutputModel .getGeneric (), java .util .Arrays .asList (dialogNodeOutputGenericModel ));
9374 assertEquals (
9475 dialogNodeOutputModel .getIntegrations (),
95- new java .util .HashMap <String , Map <String , Object >>() {
96- {
97- put (
98- "foo" ,
99- new java .util .HashMap <String , Object >() {
100- {
101- put ("foo" , "testString" );
102- }
103- });
104- }
105- });
76+ java .util .Collections .singletonMap (
77+ "foo" , java .util .Collections .singletonMap ("anyKey" , "anyValue" )));
10678 assertEquals (dialogNodeOutputModel .getModifiers (), dialogNodeOutputModifiersModel );
10779 assertEquals (dialogNodeOutputModel .get ("foo" ), "testString" );
10880
10981 DialogNodeContext dialogNodeContextModel =
11082 new DialogNodeContext .Builder ()
11183 .integrations (
112- new java .util .HashMap <String , Map <String , Object >>() {
113- {
114- put (
115- "foo" ,
116- new java .util .HashMap <String , Object >() {
117- {
118- put ("foo" , "testString" );
119- }
120- });
121- }
122- })
84+ java .util .Collections .singletonMap (
85+ "foo" , java .util .Collections .singletonMap ("anyKey" , "anyValue" )))
12386 .add ("foo" , "testString" )
12487 .build ();
12588 assertEquals (
12689 dialogNodeContextModel .getIntegrations (),
127- new java .util .HashMap <String , Map <String , Object >>() {
128- {
129- put (
130- "foo" ,
131- new java .util .HashMap <String , Object >() {
132- {
133- put ("foo" , "testString" );
134- }
135- });
136- }
137- });
90+ java .util .Collections .singletonMap (
91+ "foo" , java .util .Collections .singletonMap ("anyKey" , "anyValue" )));
13892 assertEquals (dialogNodeContextModel .get ("foo" ), "testString" );
13993
14094 DialogNodeNextStep dialogNodeNextStepModel =
@@ -151,24 +105,15 @@ public void testCreateDialogNodeOptions() throws Throwable {
151105 new DialogNodeAction .Builder ()
152106 .name ("testString" )
153107 .type ("client" )
154- .parameters (
155- new java .util .HashMap <String , Object >() {
156- {
157- put ("foo" , "testString" );
158- }
159- })
108+ .parameters (java .util .Collections .singletonMap ("anyKey" , "anyValue" ))
160109 .resultVariable ("testString" )
161110 .credentials ("testString" )
162111 .build ();
163112 assertEquals (dialogNodeActionModel .name (), "testString" );
164113 assertEquals (dialogNodeActionModel .type (), "client" );
165114 assertEquals (
166115 dialogNodeActionModel .parameters (),
167- new java .util .HashMap <String , Object >() {
168- {
169- put ("foo" , "testString" );
170- }
171- });
116+ java .util .Collections .singletonMap ("anyKey" , "anyValue" ));
172117 assertEquals (dialogNodeActionModel .resultVariable (), "testString" );
173118 assertEquals (dialogNodeActionModel .credentials (), "testString" );
174119
@@ -182,12 +127,7 @@ public void testCreateDialogNodeOptions() throws Throwable {
182127 .previousSibling ("testString" )
183128 .output (dialogNodeOutputModel )
184129 .context (dialogNodeContextModel )
185- .metadata (
186- new java .util .HashMap <String , Object >() {
187- {
188- put ("foo" , "testString" );
189- }
190- })
130+ .metadata (java .util .Collections .singletonMap ("anyKey" , "anyValue" ))
191131 .nextStep (dialogNodeNextStepModel )
192132 .title ("testString" )
193133 .type ("standard" )
@@ -211,11 +151,7 @@ public void testCreateDialogNodeOptions() throws Throwable {
211151 assertEquals (createDialogNodeOptionsModel .context (), dialogNodeContextModel );
212152 assertEquals (
213153 createDialogNodeOptionsModel .metadata (),
214- new java .util .HashMap <String , Object >() {
215- {
216- put ("foo" , "testString" );
217- }
218- });
154+ java .util .Collections .singletonMap ("anyKey" , "anyValue" ));
219155 assertEquals (createDialogNodeOptionsModel .nextStep (), dialogNodeNextStepModel );
220156 assertEquals (createDialogNodeOptionsModel .title (), "testString" );
221157 assertEquals (createDialogNodeOptionsModel .type (), "standard" );
0 commit comments