+
+ @Test
+ public void chefInfo_shouldUpdateSvcLogicContext_withFailStatusAndMsg_andThrowException_whenUsernameParamIsMissing() {
+ Map<String, String> params = ImmutableMap.of(
+ "serverAddress", "http://chefAddress",
+ "organizations", "onap");
+ checkIfInputParamsAreValidated(params);
+ }
+
+ @Test
+ public void chefInfo_shouldUpdateSvcLogicContext_withFailStatusAndMsg_andThrowException_whenServerAddressParamIsMissing() {
+ Map<String, String> params = ImmutableMap.of(
+ "username", "TestUsername",
+ "organizations", "onap");
+ checkIfInputParamsAreValidated(params);
+ }
+
+ @Test
+ public void chefInfo_shouldUpdateSvcLogicContext_withFailStatusAndMsg_andThrowException_whenOrganizationsParamIsMissing() {
+ Map<String, String> params = ImmutableMap.of(
+ "username", "TestUsername",
+ "serverAddress", "http://chefAddress");
+ checkIfInputParamsAreValidated(params);
+ }
+
+ private void checkIfInputParamsAreValidated(Map<String, String> params) {
+ // GIVEN
+ String expectedErrorMsg = "Missing mandatory param(s) such as username, serverAddress, organizations";
+ SvcLogicContext svcLogicContext = new SvcLogicContext();
+
+ // WHEN// THEN
+ assertThatExceptionOfType(SvcLogicException.class)
+ .isThrownBy(() -> chefAdapterFactory.create().chefGet(params, svcLogicContext))
+ .withMessage("Chef Adapter error:"
+ + expectedErrorMsg);
+ assertThat(svcLogicContext.getStatus()).isEqualTo("failure");
+ assertThat(svcLogicContext.getAttribute("chefServerResult.code"))
+ .isEqualTo(Integer.toString(HttpStatus.SC_UNAUTHORIZED));
+ assertThat(svcLogicContext.getAttribute("chefServerResult.message"))
+ .isEqualTo(expectedErrorMsg);
+ }
+}
\ No newline at end of file