+/*
+ * ============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.flow.controller.node;
import static org.mockito.Mockito.mock;
@Rule
public ExpectedException expectedException = ExpectedException.none();
+ private ResourceUriExtractor resourceUriExtractor;
@Before
public void setUp() {
ctx = mock(SvcLogicContext.class);
prop = mock(Properties.class);
+ resourceUriExtractor = new ResourceUriExtractor();
}
@Test
public void should_return_input_url_if_exist() throws Exception {
ctx = mock(SvcLogicContext.class);
- when(ctx.getAttribute(INPUT_URL)).thenReturn("test resource uri");
+ when(ctx.getAttribute(INPUT_URL)).thenReturn("http://localhost:8080");
- String resourceUri = ResourceUriExtractor.extractResourceUri(ctx, prop);
+ resourceUriExtractor = new ResourceUriExtractor();
+ String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
- Assert.assertEquals("test resource uri", resourceUri);
+ Assert.assertEquals("http://localhost:8080", resourceUri);
}
@Test
when(ctx.getAttribute(INPUT_CONTEXT)).thenReturn("input-context");
when(ctx.getAttribute(INPUT_SUB_CONTEXT)).thenReturn("input-sub-context");
- String resourceUri = ResourceUriExtractor.extractResourceUri(ctx, prop);
+ String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
Assert.assertEquals("http://localhost:8080/input-context/input-sub-context", resourceUri);
}
when(prop.getProperty("request-action.context")).thenReturn("ra-context");
when(prop.getProperty("request-action.sub-context")).thenReturn("ra-sub-context");
- String resourceUri = ResourceUriExtractor.extractResourceUri(ctx, prop);
+ String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
Assert.assertEquals("http://localhost:8080/ra-context/ra-sub-context", resourceUri);
}
expectedException.expect(Exception.class);
expectedException.expectMessage("Could Not found the context for operation null");
- ResourceUriExtractor.extractResourceUri(ctx, prop);
+ resourceUriExtractor.extractResourceUri(ctx, prop);
}
}
\ No newline at end of file