Skip to content

Commit b087caf

Browse files
committed
added unit test for detect sentiment
1 parent fa035ab commit b087caf

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed
Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
" Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
" SPDX-License-Identifier: Apache-2.0
13

24
CLASS ltc_zcl_aws1_cpd_actions DEFINITION FOR TESTING
35
DURATION SHORT
46
RISK LEVEL HARMLESS.
57

68
PRIVATE SECTION.
7-
DATA:
8-
f_cut TYPE REF TO zcl_aws1_cpd_actions. "class under test
9+
CONSTANTS cv_pfl TYPE /aws1/rt_profile_id VALUE 'ZCODE_DEMO'.
10+
CONSTANTS cv_languagecode VALUE |EN|.
911

1012
METHODS: detectsentiment FOR TESTING.
1113
ENDCLASS. "ltc_Zcl_Aws1_Cpd_Actions
@@ -14,12 +16,23 @@ ENDCLASS. "ltc_Zcl_Aws1_Cpd_Actions
1416
CLASS ltc_zcl_aws1_cpd_actions IMPLEMENTATION.
1517

1618
METHOD detectsentiment.
17-
18-
19-
19+
DATA lo_output TYPE REF TO /aws1/cl_cpddetectsentimentrsp.
20+
DATA(lv_expected_output) = |POSITIVE|.
21+
22+
ao_cpd_actions->detectsentiment(
23+
IMPORTING
24+
oo_result = lo_output ).
25+
26+
DATA(lv_found) = abap_true.
27+
IF lo_output->has_sentiment() = abap_true.
28+
IF lo_output->get_sentiment() = lv_expected_output.
29+
lv_found = abap_true.
30+
ENDIF.
31+
ENDIF.
32+
33+
cl_abap_unit_assert=>assert_true(
34+
act = lv_found
35+
msg = |Sentiment detection failed| ).
2036
ENDMETHOD.
2137

22-
23-
24-
2538
ENDCLASS.

0 commit comments

Comments
 (0)