Returning null for unresolved variables 98/88698/3
authorottero <rodrigo.ottero@est.tech>
Tue, 28 May 2019 09:25:45 +0000 (09:25 +0000)
committerYuriy Malakov <Yuriy.Malakov@att.com>
Wed, 29 May 2019 10:25:18 +0000 (10:25 +0000)
commitbef9ae59c3911a39f0e94f4dd44f128fe8b73706
tree18f10ca59e2f87c04e125db677ac1a4dc1f754d4
parent7679f2d1b19d8192e7a88e9b66687f7960315353
Returning null for unresolved variables

When Blueprints Processor was not able to evaluate a variable, it would
set its value to null.

The expected behaviour would be to set the value to the default repres-
entation in the formal notation as defined by Apache Velocity, which is
a dollar followed by the name of the variable between curly braces. For
example, if the value of the variable pnf-id could not be evaluated in
runtime, its value would be defined as the string "${pnf-id}".

The problem happened during evaluation of the variables that would be
later sent to the template-meshing code for processing.

The fix was to add a check before the value was assigned to the varia-
ble; if the was not null, the assignment will happen normally. Otherwi-
se, if the evaluation resolves to null, the variable receives the defa-
ult value (string "${<variable name>}").

Besides the tests that were put in place to test the code changed for
this fix, two tests were added to the existing test case of the templa-
te meshing code, to act as regression test.

Change-Id: I635afb1eba4c0d45b821811f0119fa6c87ea9542
Issue-ID: CCSDK-1358
Signed-off-by: ottero <rodrigo.ottero@est.tech>
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt [new file with mode: 0644]