+ @Before
+ public void setUp() throws Exception {
+
+ uriExtractorMock = mock(ResourceUriExtractor.class);
+ transactionHandlerMock = mock(TransactionHandler.class);
+ restExecutorMock = mock(RestExecutor.class);
+ ctxMock = mock(SvcLogicContext.class);
+ transaction = mock(Transaction.class);
+
+ // given
+ params = new HashMap<>();
+
+ HashMap<String, String> restResponseMap = new HashMap<>();
+ restResponseMap.put(REST_RESPONSE, REST_BODY_RESPONSE.replaceAll("'", "\""));
+
+ when(uriExtractorMock
+ .extractResourceUri(any(SvcLogicContext.class), any(Properties.class)))
+ .thenReturn(RESOURCE_URI);
+ when(transactionHandlerMock
+ .buildTransaction(any(SvcLogicContext.class), any(Properties.class), eq(RESOURCE_URI)))
+ .thenReturn(transaction);
+ when(restExecutorMock.execute(eq(transaction), any(SvcLogicContext.class)))
+ .thenReturn(restResponseMap);
+
+ EnvVariables envVariables = new EnvVariables(envKey -> MOCK_ENV);
+ restServiceNode = new RestServiceNode(transactionHandlerMock, restExecutorMock, uriExtractorMock, envVariables);
+ }
+
+ @Test
+ public void should_send_request() throws Exception {
+ // given
+ params.put(INPUT_PARAM_RESPONSE_PREFIX, "some-prefix");
+
+ // when
+ restServiceNode.sendRequest(params, ctxMock);
+
+ // then
+ verify(uriExtractorMock)
+ .extractResourceUri(eq(ctxMock), any(Properties.class));
+ verify(transactionHandlerMock)
+ .buildTransaction(eq(ctxMock), any(Properties.class), eq(RESOURCE_URI));
+ verify(restExecutorMock)
+ .execute(transaction, ctxMock);
+ verifyNoMoreInteractions(uriExtractorMock, transactionHandlerMock, restExecutorMock);
+ }
+
+ @Test
+ public void should_rethrow_exception_from_uri_extractor() throws Exception {
+ when(uriExtractorMock
+ .extractResourceUri(eq(ctxMock), any(Properties.class)))
+ .thenThrow(new Exception("resource uri exception"));