public class ChefApiClientImpl implements ChefApiClient {
private final HttpClient httpClient;
- private final ChefApiHeaderFactory chefApiHeaderFactory;
- private String endpoint;
- private String userId;
- private String pemPath;
- private String organizations;
+ private final String endpoint;
+ private final HttpHeaderFactory httpHeaderFactory;
- public ChefApiClientImpl(HttpClient httpClient, ChefApiHeaderFactory chefApiHeaderFactory,
- String endpoint, String organizations, String userId, String pemPath) {
+ public ChefApiClientImpl(HttpClient httpClient, String endpoint, HttpHeaderFactory httpHeaderFactory) {
this.httpClient = httpClient;
- this.chefApiHeaderFactory = chefApiHeaderFactory;
this.endpoint = endpoint;
- this.organizations = organizations;
- this.userId = userId;
- this.pemPath = pemPath;
+ this.httpHeaderFactory = httpHeaderFactory;
}
@Override
OngoingRequestBuilder requestBuilder = ChefRequestBuilder.newRequestTo(endpoint)
.httpGet()
.withPath(path)
- .withHeaders(chefApiHeaderFactory.create("GET", path, "", userId, organizations, pemPath));
+ .withHeaders(httpHeaderFactory.create("GET", path, ""));
return execute(requestBuilder);
}
OngoingRequestBuilder requestBuilder = ChefRequestBuilder.newRequestTo(endpoint)
.httpDelete()
.withPath(path)
- .withHeaders(chefApiHeaderFactory.create("DELETE", path, "", userId, organizations, pemPath));
+ .withHeaders(httpHeaderFactory.create("DELETE", path, ""));
return execute(requestBuilder);
}
OngoingRequestBuilder requestBuilder = ChefRequestBuilder.newRequestTo(endpoint)
.httpPost(body)
.withPath(path)
- .withHeaders(chefApiHeaderFactory.create("POST", path, body, userId, organizations, pemPath));
+ .withHeaders(httpHeaderFactory.create("POST", path, body));
return execute(requestBuilder);
}
OngoingRequestBuilder requestBuilder = ChefRequestBuilder.newRequestTo(endpoint)
.httpPut(body)
.withPath(path)
- .withHeaders(chefApiHeaderFactory.create("PUT", path, body, userId, organizations, pemPath));
+ .withHeaders(httpHeaderFactory.create("PUT", path, body));
return execute(requestBuilder);
}
}
}
}
+
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. All rights reserved.
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.appc.adapter.chef.chefclient.impl;
+
+import com.google.common.collect.ImmutableMap;
+
+@FunctionalInterface
+public interface HttpHeaderFactory {
+
+ ImmutableMap<String, String> create(String methodName, String requestPath, String body);
+}
private static final String USER_ID = "testUser";
private static final String REQUEST_PATH = "/test/path";
private static final String BODY = "SOME BODY STRING";
+ private static final String PEM_FILEPATH = "path/to/pemFile";
private static final ImmutableMap<String, String> HEADERS = ImmutableMap.<String, String>builder()
.put("Content-type", "application/json")
.put("Accept", "application/json")
@InjectMocks
private ChefApiClientFactory chefApiClientFactory;
- private static final String PEM_FILEPATH = "path/to/pemFile";
private ChefApiClient chefApiClient;
@Before