/*
- * ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 Nokia.
- * =============================================================================
- * 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
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright (C) 2018 Nokia.
+ * ============================================================================= 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
+ * 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.
+ * 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.so.cloudify.connector.http;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
-
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.http.HttpRequest;
}
private void assertHttpUriRequestFor(String methodName, Class<? extends HttpUriRequest> expectedHttpMethodClass)
- throws URISyntaxException, ProtocolException {
+ throws URISyntaxException, ProtocolException {
// GIVEN
HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS);
given(request.getRequestLine().getMethod()).willReturn(methodName);
HttpContext context = null;
URI expectedUri = new URI("http://localhost/host");
// WHEN
- HttpUriRequest httpUriRequest = new TestableHttpClientRedirectStrategy(expectedUri)
- .getRedirect(request, response, context);
+ HttpUriRequest httpUriRequest =
+ new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context);
// THEN
assertThat(httpUriRequest).isInstanceOf(expectedHttpMethodClass);
assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri);
URI expectedUri = new URI("http://localhost/host");
HttpContext context = null;
// WHEN
- HttpUriRequest httpUriRequest = new TestableHttpClientRedirectStrategy(expectedUri)
- .getRedirect(request, response, context);
+ HttpUriRequest httpUriRequest =
+ new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context);
// THEN
assertThat(httpUriRequest).isInstanceOf(HttpGet.class);
assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri);
}
@Test
- public void getRedirect_shouldCopyHttpRequestAndSetNewUri_forMovedTemporarilyStatus() throws URISyntaxException, ProtocolException {
+ public void getRedirect_shouldCopyHttpRequestAndSetNewUri_forMovedTemporarilyStatus()
+ throws URISyntaxException, ProtocolException {
assertHttpRequestIsCopied(HttpStatus.SC_MOVED_TEMPORARILY);
}
@Test
- public void getRedirect_shouldCopyHttpRequestAndSetNewUri_forTemporaryRedirectStatus() throws URISyntaxException, ProtocolException {
+ public void getRedirect_shouldCopyHttpRequestAndSetNewUri_forTemporaryRedirectStatus()
+ throws URISyntaxException, ProtocolException {
assertHttpRequestIsCopied(HttpStatus.SC_TEMPORARY_REDIRECT);
}
URI expectedUri = new URI("http://localhost/host");
HttpContext context = null;
// WHEN
- HttpUriRequest httpUriRequest = new TestableHttpClientRedirectStrategy(expectedUri)
- .getRedirect(request, response, context);
+ HttpUriRequest httpUriRequest =
+ new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context);
// THEN
assertThat(httpUriRequest).isInstanceOf(HttpGet.class);
assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri);
public TestableHttpClientRedirectStrategy(URI expectedUri) {
this.expectedUri = expectedUri;
}
+
@Override
public URI getLocationURI(HttpRequest request, HttpResponse response, HttpContext context) {
return expectedUri;
}
}
-}
\ No newline at end of file
+}