Eliminate constructors with side-effects 55/95755/1
authorJim Hahn <jrh3@att.com>
Mon, 16 Sep 2019 15:38:20 +0000 (11:38 -0400)
committerJim Hahn <jrh3@att.com>
Mon, 16 Sep 2019 16:27:50 +0000 (12:27 -0400)
commit00ab9f38e08643acda3b560e01236ced0d77d5c2
treeae1e560e9918be4de1dbbacad0e144f589ec761d
parentaf2e4018c92b0fb311f60dfe507335b12e2935a4
Eliminate constructors with side-effects

Several of the Gson and Jackson handlers take a GsonBuilder, which
they then configure with additional adapters prior to create a Gson
object that they subsequently use.  The code has been modified so
that the constructors no longer take a GsonBuilder, thus eliminating
the side-effects that they had on the builders.  Instead, a
configBuilder() method has been added to the handler classes that
makes it clear tht they modify the GsonBuilder.

This also has the advantage that classes that want a Gson object
configured per a given handler need only call that handler's
configBuilder() method; previously, they had to constructor the
handler and then retrieve its gson object.

Also updated a few tests to specify the HTTP "Accept" header to ensure
that return results are in yaml format.

Change-Id: I2ef98198041ff9f73913d01ee6ee14ecf20ba617
Issue-ID: POLICY-2081
Signed-off-by: Jim Hahn <jrh3@att.com>
gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java
gson/src/main/java/org/onap/policy/common/gson/JacksonHandler.java
policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlJacksonHandler.java
policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlMessageBodyHandler.java
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java
utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtilsBuilder.java