/**\r
* Copyright 2017 ZTE Corporation.\r
- *\r
+ * <p>\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
+ * <p>\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * <p>\r
* Unless required by applicable law or agreed to in writing, software\r
* distributed under the License is distributed on an "AS IS" BASIS,\r
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
import org.apache.http.impl.client.HttpClients;\r
import org.junit.Before;\r
import org.junit.Rule;\r
+import org.junit.Test;\r
import org.junit.rules.ExpectedException;\r
+import org.junit.runner.RunWith;\r
+import org.onap.holmes.common.utils.HttpsUtils;\r
import org.onap.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;\r
import org.powermock.api.easymock.PowerMock;\r
+import org.powermock.core.classloader.annotations.PowerMockIgnore;\r
import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
import org.powermock.modules.junit4.rule.PowerMockRule;\r
+import org.powermock.reflect.Whitebox;\r
\r
-@PrepareForTest({HttpClients.class, CloseableHttpClient.class})\r
+import java.util.HashMap;\r
+\r
+import static org.hamcrest.MatcherAssert.assertThat;\r
+import static org.hamcrest.Matchers.equalTo;\r
+\r
+@PrepareForTest({HttpClients.class, CloseableHttpClient.class, HttpsUtils.class})\r
+@PowerMockIgnore("javax.net.ssl.*")\r
+@RunWith(PowerMockRunner.class)\r
public class EngineServiceTest {\r
\r
@Rule\r
public ExpectedException thrown = ExpectedException.none();\r
- @Rule\r
- public PowerMockRule powerMockRule = new PowerMockRule();\r
private EngineService engineService;\r
private HttpResponse httpResponseMock;\r
private CloseableHttpClient closeableHttpClient;\r
correlationDeployRule4Engine.setContent("{\"package\":\"test\"}");\r
correlationDeployRule4Engine.setEngineId("engine_id");\r
}\r
+\r
+ @Test\r
+ public void testEngineService_createHeaders_ok() throws Exception {\r
+ PowerMock.resetAll();\r
+ HashMap<String, String> headers = Whitebox.invokeMethod(engineService, "createHeaders");\r
+ assertThat(headers.get("Content-Type"), equalTo("application/json"));\r
+ assertThat(headers.get("Accept"), equalTo("application/json"));\r
+ }\r
+\r
+ @Test\r
+ public void testEngineService_closeHttpClient_ok() throws Exception {\r
+ PowerMock.resetAll();\r
+ CloseableHttpClient closeableHttpClient = HttpsUtils\r
+ .getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);\r
+ Whitebox.invokeMethod(engineService, "closeHttpClient", closeableHttpClient);\r
+ }\r
+\r
}
\ No newline at end of file