common/RestClient.java
file name:RestClient.java
Change-Id: Idabb6ed057ab678178e11092eaf3d307c4f51dc7
Issue-ID: VFC-857
Signed-off-by: ajay priyadarshi <ajay.priyadarshi@ril.com>
private static final String HTTP = "http";\r
private static final Logger logger = LoggerFactory.getLogger(RestClient.class);\r
\r
private static final String HTTP = "http";\r
private static final Logger logger = LoggerFactory.getLogger(RestClient.class);\r
\r
- //PublicExposureUsedInTest\r
- public static boolean isTest = false;\r
+ private static boolean isTest = false;\r
\r
public enum HttpMethod {\r
GET, POST, PUT, DELETE\r
\r
public enum HttpMethod {\r
GET, POST, PUT, DELETE\r
return executeHttpDeleteDeploy(HttpMethod.DELETE, ip, port, url);\r
}\r
\r
return executeHttpDeleteDeploy(HttpMethod.DELETE, ip, port, url);\r
}\r
\r
+ public static boolean getIsTest(){\r
+ return isTest;\r
+ }\r
+\r
+ public static void setIsTest(boolean arg){\r
+ isTest = arg;\r
+ }\r
+\r
public class ActivitiServiceConsumerTest {\r
@Test\r
public void undeploybpmnfile() throws ClientProtocolException, IOException {\r
public class ActivitiServiceConsumerTest {\r
@Test\r
public void undeploybpmnfile() throws ClientProtocolException, IOException {\r
- RestClient.isTest = true;\r
+ RestClient.setIsTest(true);\r
RestResponse response = ActivitiServiceConsumer.undeploybpmnfile("22");\r
Assert.assertTrue(response != null);\r
RestResponse response = ActivitiServiceConsumer.undeploybpmnfile("22");\r
Assert.assertTrue(response != null);\r
- RestClient.isTest = false;\r
+ RestClient.setIsTest(false);\r
}\r
\r
@Test\r
public void startBpmnProcess() throws Exception {\r
}\r
\r
@Test\r
public void startBpmnProcess() throws Exception {\r
- RestClient.isTest = true;\r
+ RestClient.setIsTest(true);\r
RestResponse response =\r
ActivitiServiceConsumer.startBpmnProcess(mock(ActivitiStartProcessRequest.class));\r
Assert.assertTrue(response != null);\r
RestResponse response =\r
ActivitiServiceConsumer.startBpmnProcess(mock(ActivitiStartProcessRequest.class));\r
Assert.assertTrue(response != null);\r
- RestClient.isTest = false;\r
+ RestClient.setIsTest(false);\r
}\r
\r
@Test\r
public void testDeleteDeployProcess() throws Exception {\r
}\r
\r
@Test\r
public void testDeleteDeployProcess() throws Exception {\r
- RestClient.isTest = true;\r
+ RestClient.setIsTest(true);\r
RestResponse response = ActivitiServiceConsumer.deleteDeployProcess("22");\r
Assert.assertTrue(response != null);\r
RestResponse response = ActivitiServiceConsumer.deleteDeployProcess("22");\r
Assert.assertTrue(response != null);\r
- RestClient.isTest = false;\r
+ RestClient.setIsTest(false);\r
}\r
\r
@Test\r
public void testDeleteDeployProcessReturnNull() throws Exception {\r
}\r
\r
@Test\r
public void testDeleteDeployProcessReturnNull() throws Exception {\r
- RestClient.isTest = false;\r
+ RestClient.setIsTest(false);\r
RestResponse response = ActivitiServiceConsumer.deleteDeployProcess("22");\r
if (response != null) {\r
Assert.assertTrue(response.getResult() == null);\r
RestResponse response = ActivitiServiceConsumer.deleteDeployProcess("22");\r
if (response != null) {\r
Assert.assertTrue(response.getResult() == null);\r
\r
@Test\r
public void testStartProcessShouldReturnResponse() throws Exception {\r
\r
@Test\r
public void testStartProcessShouldReturnResponse() throws Exception {\r
- RestClient.isTest = true;\r
+ RestClient.setIsTest(true);\r
RestResponse response =\r
ActivitiServiceConsumer.startProcess(mock(ActivitiStartProcessRequest.class));\r
Assert.assertTrue(response != null);\r
RestResponse response =\r
ActivitiServiceConsumer.startProcess(mock(ActivitiStartProcessRequest.class));\r
Assert.assertTrue(response != null);\r
- RestClient.isTest = false;\r
+ RestClient.setIsTest(false);\r
}\r
\r
@Test\r
public void testStartProcessShouldReturnNull() {\r
}\r
\r
@Test\r
public void testStartProcessShouldReturnNull() {\r
- RestClient.isTest = false;\r
+ RestClient.setIsTest(false);\r
RestResponse response =\r
ActivitiServiceConsumer.startProcess(mock(ActivitiStartProcessRequest.class));\r
Assert.assertTrue(response.getResult() == null);\r
RestResponse response =\r
ActivitiServiceConsumer.startProcess(mock(ActivitiStartProcessRequest.class));\r
Assert.assertTrue(response.getResult() == null);\r
\r
@Test\r
public void deploybpmnfile() throws Exception {\r
\r
@Test\r
public void deploybpmnfile() throws Exception {\r
- RestClient.isTest = true;\r
+ RestClient.setIsTest(true);\r
WorkflowAppConfig workflowAppConfig = new WorkflowAppConfig();\r
MsbClientConfig msbClientConfig = new MsbClientConfig();\r
msbClientConfig.setMsbSvrPort(2);\r
WorkflowAppConfig workflowAppConfig = new WorkflowAppConfig();\r
MsbClientConfig msbClientConfig = new MsbClientConfig();\r
msbClientConfig.setMsbSvrPort(2);\r
when(ins.read(Mockito.anyObject())).thenReturn(-21);\r
ActivitiDeployResponse result = ActivitiServiceConsumer.deploybpmnfile(ins, "result");\r
Assert.assertTrue(result == null);\r
when(ins.read(Mockito.anyObject())).thenReturn(-21);\r
ActivitiDeployResponse result = ActivitiServiceConsumer.deploybpmnfile(ins, "result");\r
Assert.assertTrue(result == null);\r
- RestClient.isTest = false;\r
+ RestClient.setIsTest(false);\r
-}
\ No newline at end of file
\r
@Test\r
public final void testDeployBpmnFile() throws Exception {\r
\r
@Test\r
public final void testDeployBpmnFile() throws Exception {\r
- RestClient.isTest = true;\r
+ RestClient.setIsTest(true);\r
InputStream fileInputStream = mock(InputStream.class);\r
FormDataContentDisposition f = mock(FormDataContentDisposition.class);\r
String filename = "test";\r
when(fileInputStream.read(Mockito.anyObject())).thenReturn(-21);\r
Response reponse = workflowInstanceWrapper.deployBpmnFile(filename, fileInputStream, f);\r
Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), reponse.getStatus());\r
InputStream fileInputStream = mock(InputStream.class);\r
FormDataContentDisposition f = mock(FormDataContentDisposition.class);\r
String filename = "test";\r
when(fileInputStream.read(Mockito.anyObject())).thenReturn(-21);\r
Response reponse = workflowInstanceWrapper.deployBpmnFile(filename, fileInputStream, f);\r
Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), reponse.getStatus());\r
- RestClient.isTest = false;\r
+ RestClient.setIsTest(false);\r
}\r
\r
@Test\r
public final void testUndeployBpmnFile() throws Exception {\r
}\r
\r
@Test\r
public final void testUndeployBpmnFile() throws Exception {\r
- RestClient.isTest = true;\r
+ RestClient.setIsTest(true);\r
RestResponse response = WorkflowInstanceWrapper.getInstance().undeployBpmnFile(null);\r
if (response != null) {\r
Assert.assertTrue(response.getResult() == null);\r
}\r
RestResponse response = WorkflowInstanceWrapper.getInstance().undeployBpmnFile(null);\r
if (response != null) {\r
Assert.assertTrue(response.getResult() == null);\r
}\r
- RestClient.isTest = false;\r
+ RestClient.setIsTest(false);\r
}\r
\r
@Test\r
public final void testStartProcess() throws Exception {\r
}\r
\r
@Test\r
public final void testStartProcess() throws Exception {\r
- RestClient.isTest = true;\r
+ RestClient.setIsTest(true);\r
ActivitiStartProcessRequest startProcessRequest = new ActivitiStartProcessRequest();\r
startProcessRequest.setProcessDefinitionKey("first");\r
StartProcessRequest tt = new StartProcessRequest();\r
tt.setProcessDefinitionKey("first");\r
Response reponse = workflowInstanceWrapper.startProcess(tt);\r
Assert.assertEquals(Response.Status.OK.getStatusCode(), reponse.getStatus());\r
ActivitiStartProcessRequest startProcessRequest = new ActivitiStartProcessRequest();\r
startProcessRequest.setProcessDefinitionKey("first");\r
StartProcessRequest tt = new StartProcessRequest();\r
tt.setProcessDefinitionKey("first");\r
Response reponse = workflowInstanceWrapper.startProcess(tt);\r
Assert.assertEquals(Response.Status.OK.getStatusCode(), reponse.getStatus());\r
- RestClient.isTest = false;\r
+ RestClient.setIsTest(false);\r