import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+
import com.google.common.base.Optional;
import java.net.URISyntaxException;
import java.util.Arrays;
public class MountPointSwaggerTest {
private static final String HTTP_URL = "http://localhost/path";
- private static final YangInstanceIdentifier instanceId = YangInstanceIdentifier.builder()
- .node(QName.create("nodes"))
- .node(QName.create("node"))
- .nodeWithKey(QName.create("node"), QName.create("id"), "123").build();
- private static final String INSTANCE_URL = "nodes/node/123/";
+ private static final YangInstanceIdentifier INSTANCE_ID = YangInstanceIdentifier.builder()
+ .node(QName.create("", "nodes"))
+ .node(QName.create("", "node"))
+ .nodeWithKey(QName.create("", "node"), QName.create("", "id"), "123").build();
+ private static final String INSTANCE_URL = "/nodes/node/123/";
private MountPointSwagger swagger;
private DocGenTestHelper helper;
private SchemaContext schemaContext;
final UriInfo mockInfo = setUpSwaggerForDocGeneration();
assertEquals(0, this.swagger.getInstanceIdentifiers().size());
- this.swagger.onMountPointCreated(instanceId); // add this ID into the list of
+ this.swagger.onMountPointCreated(INSTANCE_ID); // add this ID into the list of
// mount points
assertEquals(1, this.swagger.getInstanceIdentifiers().size());
assertEquals((Long) 1L, this.swagger.getInstanceIdentifiers().entrySet().iterator().next()
.getValue());
assertEquals(INSTANCE_URL, this.swagger.getInstanceIdentifiers().entrySet().iterator().next()
.getKey());
- this.swagger.onMountPointRemoved(instanceId); // remove ID from list of mount
+ this.swagger.onMountPointRemoved(INSTANCE_ID); // remove ID from list of mount
// points
assertEquals(0, this.swagger.getInstanceIdentifiers().size());
}
@Test
public void testGetResourceListGoodId() throws Exception {
final UriInfo mockInfo = setUpSwaggerForDocGeneration();
- this.swagger.onMountPointCreated(instanceId); // add this ID into the list of
+ this.swagger.onMountPointCreated(INSTANCE_ID); // add this ID into the list of
// mount points
final ResourceList resourceList = this.swagger.getResourceList(mockInfo, 1L);
@Test
public void testGetDataStoreApi() throws Exception {
final UriInfo mockInfo = setUpSwaggerForDocGeneration();
- this.swagger.onMountPointCreated(instanceId); // add this ID into the list of
+ this.swagger.onMountPointCreated(INSTANCE_ID); // add this ID into the list of
// mount points
+
final ApiDeclaration mountPointApi = this.swagger.getMountPointApi(mockInfo, 1L, "Datastores", "-");
assertNotNull("failed to find Datastore API", mountPointApi);
final List<Api> apis = mountPointApi.getApis();
.getNotes());
}
final Set<String> expectedApis = new TreeSet<>(Arrays.asList(new String[] {
- "/config/" + INSTANCE_URL + "yang-ext:mount/",
- "/operational/" + INSTANCE_URL + "yang-ext:mount/",
- "/operations/" + INSTANCE_URL + "yang-ext:mount/", }));
+ "/config" + INSTANCE_URL + "yang-ext:mount",
+ "/operational" + INSTANCE_URL + "yang-ext:mount",
+ "/operations" + INSTANCE_URL + "yang-ext:mount",}));
assertEquals(expectedApis, actualApis);
}
when(mountPoint.getSchemaContext()).thenReturn(context);
final DOMMountPointService service = mock(DOMMountPointService.class);
- when(service.getMountPoint(instanceId)).thenReturn(Optional.of(mountPoint));
+ when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint));
this.swagger.setMountService(service);
this.swagger.setGlobalSchema(schemaService);