import org.opendaylight.controller.sal.core.api.Broker;
import org.opendaylight.netconf.sal.rest.api.RestConnector;
import org.opendaylight.netconf.sal.restconf.impl.RestconfProviderImpl;
-import org.opendaylight.restconf.rest.RestConnectorProvider;
+import org.opendaylight.restconf.RestConnectorProvider;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
/**
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import org.opendaylight.restconf.rest.api.services.schema.RestconfSchemaService;
+import org.opendaylight.restconf.rest.services.api.RestconfSchemaService;
/**
* @deprecated do not use this api. It is replaced by
import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
-import org.opendaylight.restconf.rest.api.services.RestconfModulesService;
-import org.opendaylight.restconf.rest.api.services.RestconfOperationsService;
-import org.opendaylight.restconf.rest.api.services.RestconfStreamsService;
+import org.opendaylight.restconf.rest.services.api.RestconfModulesService;
+import org.opendaylight.restconf.rest.services.api.RestconfOperationsService;
+import org.opendaylight.restconf.rest.services.api.RestconfStreamsService;
import org.opendaylight.restconf.restful.services.api.RestconfDataService;
import org.opendaylight.restconf.restful.services.api.RestconfInvokeOperationsService;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest;
+package org.opendaylight.restconf;
import com.google.common.base.Preconditions;
import java.util.Collection;
import org.opendaylight.controller.sal.core.api.Provider;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.netconf.sal.rest.api.RestConnector;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
+import org.opendaylight.restconf.common.handlers.impl.SchemaContextHandlerImpl;
import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler;
import org.opendaylight.restconf.rest.handlers.impl.DOMMountPointServiceHandlerImpl;
-import org.opendaylight.restconf.rest.impl.schema.context.SchemaContextHandlerImpl;
-import org.opendaylight.restconf.rest.impl.services.Draft11ServicesWrapperImpl;
+import org.opendaylight.restconf.rest.services.impl.Draft11ServicesWrapperImpl;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest;
+package org.opendaylight.restconf;
import com.google.common.collect.ImmutableSet;
import java.util.HashSet;
import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContentYinBodyWriter;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter;
-import org.opendaylight.restconf.rest.impl.services.Draft11ServicesWrapperImpl;
+import org.opendaylight.restconf.rest.services.impl.Draft11ServicesWrapperImpl;
public class RestconfApplication extends Application {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.api.schema.context;
+package org.opendaylight.restconf.common.handlers.api;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.impl.schema.context;
+package org.opendaylight.restconf.common.handlers.impl;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.impl.services;
+package org.opendaylight.restconf.common.references;
import java.lang.ref.SoftReference;
import java.net.URI;
* {@link SchemaContext}.
*
*/
-final class SchemaContextRef {
+public final class SchemaContextRef {
private final SoftReference<SchemaContext> schemaContextRef;
/**
* Get {@link Module} by ietf-restconf qname from
- * {@link Draft09.RestconfModule}
+ * {@link Draft11.RestconfModule}
*
* @return {@link Module}
*/
*
* @param mountPoint
* - mount point
- * @param qname
+ * @param moduleQname
* - {@link QName} of module
* @return {@link Module}
*/
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.api.services;
+package org.opendaylight.restconf.rest.services.api;
import javax.ws.rs.Path;
-import org.opendaylight.restconf.rest.api.services.schema.RestconfSchemaService;
/**
* Wrapper for all services:
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.api.services;
+package org.opendaylight.restconf.rest.services.api;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.api.services;
+package org.opendaylight.restconf.rest.services.api;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.api.services.schema;
+package org.opendaylight.restconf.rest.services.api;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.api.services;
+package org.opendaylight.restconf.rest.services.api;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.impl.services;
+package org.opendaylight.restconf.rest.services.impl;
import javax.ws.rs.core.UriInfo;
import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext;
import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
-import org.opendaylight.restconf.rest.api.services.Draft11ServicesWrapper;
-import org.opendaylight.restconf.rest.api.services.RestconfModulesService;
-import org.opendaylight.restconf.rest.api.services.RestconfOperationsService;
-import org.opendaylight.restconf.rest.api.services.RestconfStreamsService;
-import org.opendaylight.restconf.rest.api.services.schema.RestconfSchemaService;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler;
+import org.opendaylight.restconf.rest.services.api.Draft11ServicesWrapper;
+import org.opendaylight.restconf.rest.services.api.RestconfModulesService;
+import org.opendaylight.restconf.rest.services.api.RestconfOperationsService;
+import org.opendaylight.restconf.rest.services.api.RestconfSchemaService;
+import org.opendaylight.restconf.rest.services.api.RestconfStreamsService;
/**
* Implementation of {@link Draft11ServicesWrapper}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.impl.services;
+package org.opendaylight.restconf.rest.services.impl;
import com.google.common.base.Preconditions;
import java.util.Collections;
import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
import org.opendaylight.restconf.Draft11;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
-import org.opendaylight.restconf.rest.api.services.RestconfModulesService;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
+import org.opendaylight.restconf.common.references.SchemaContextRef;
import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler;
+import org.opendaylight.restconf.rest.services.api.RestconfModulesService;
import org.opendaylight.restconf.utils.RestconfConstants;
import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeUtil;
import org.opendaylight.restconf.utils.parser.ParserIdentifier;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.impl.services;
+package org.opendaylight.restconf.rest.services.impl;
import javax.ws.rs.core.UriInfo;
import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
-import org.opendaylight.restconf.rest.api.services.RestconfOperationsService;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler;
+import org.opendaylight.restconf.rest.services.api.RestconfOperationsService;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.impl.services;
+package org.opendaylight.restconf.rest.services.impl;
import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
-import org.opendaylight.restconf.rest.api.services.schema.RestconfSchemaService;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
+import org.opendaylight.restconf.common.references.SchemaContextRef;
import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler;
+import org.opendaylight.restconf.rest.services.api.RestconfSchemaService;
import org.opendaylight.restconf.utils.parser.ParserIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.restconf.rest.impl.services;
+package org.opendaylight.restconf.rest.services.impl;
import com.google.common.base.Preconditions;
import java.util.Set;
import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
import org.opendaylight.netconf.sal.streams.listeners.Notificator;
import org.opendaylight.restconf.Draft11;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
-import org.opendaylight.restconf.rest.api.services.RestconfStreamsService;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
+import org.opendaylight.restconf.common.references.SchemaContextRef;
+import org.opendaylight.restconf.rest.services.api.RestconfStreamsService;
import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeUtil;
import org.opendaylight.restconf.utils.schema.context.RestconfSchemaUtil;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
version="3.0">
<servlet>
- <servlet-name>Restconf</servlet-name>
+ <servlet-name>JAXRSRestconf</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
- <param-value>org.opendaylight.restconf.rest.RestconfApplication</param-value>
+ <param-value>org.opendaylight.netconf.sal.rest.impl.RestconfApplication</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet>
- <servlet-name>JAXRSRestconf</servlet-name>
+ <servlet-name>Restconf</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
- <param-value>org.opendaylight.netconf.sal.rest.impl.RestconfApplication</param-value>
+ <param-value>org.opendaylight.restconf.RestconfApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.controller.sal.core.api.Broker;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
+import org.opendaylight.restconf.RestConnectorProvider;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
@Before
public void init() {
MockitoAnnotations.initMocks(this);
- connectorProvider = new RestConnectorProvider();
+ this.connectorProvider = new RestConnectorProvider();
}
/**
*/
@Test
public void restConnectorProviderInitTest() {
- assertNotNull("Connector provider should be initialized and not null", connectorProvider);
+ assertNotNull("Connector provider should be initialized and not null", this.connectorProvider);
}
/**
@Test
public void successfulRegistrationTest() {
// prepare conditions
- when(mockSession.getService(SchemaService.class)).thenReturn(mockSchemaService);
- when(mockSession.getService(DOMMountPointService.class)).thenReturn(mockMountPointService);
+ when(this.mockSession.getService(SchemaService.class)).thenReturn(this.mockSchemaService);
+ when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(this.mockMountPointService);
// test
- connectorProvider.onSessionInitiated(mockSession);
+ this.connectorProvider.onSessionInitiated(this.mockSession);
// verify interactions
- verify(mockSession, times(1)).getService(SchemaService.class);
- verify(mockSession, times(1)).getService(DOMMountPointService.class);
- verify(mockSchemaService, times(1)).registerSchemaContextListener(Mockito.any(SchemaContextHandler.class));
+ verify(this.mockSession, times(1)).getService(SchemaService.class);
+ verify(this.mockSession, times(1)).getService(DOMMountPointService.class);
+ verify(this.mockSchemaService, times(1)).registerSchemaContextListener(Mockito.any(SchemaContextHandler.class));
}
/**
@Test
public void successfulRegistrationWithoutMountPointTest() {
// prepare conditions
- when(mockSession.getService(SchemaService.class)).thenReturn(mockSchemaService);
- when(mockSession.getService(DOMMountPointService.class)).thenReturn(null);
+ when(this.mockSession.getService(SchemaService.class)).thenReturn(this.mockSchemaService);
+ when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(null);
// test
- connectorProvider.onSessionInitiated(mockSession);
+ this.connectorProvider.onSessionInitiated(this.mockSession);
// verify interactions
- verify(mockSession, times(1)).getService(SchemaService.class);
- verify(mockSession, times(1)).getService(DOMMountPointService.class);
- verify(mockSchemaService, times(1)).registerSchemaContextListener(Mockito.any(SchemaContextHandler.class));
+ verify(this.mockSession, times(1)).getService(SchemaService.class);
+ verify(this.mockSession, times(1)).getService(DOMMountPointService.class);
+ verify(this.mockSchemaService, times(1)).registerSchemaContextListener(Mockito.any(SchemaContextHandler.class));
}
/**
*/
@Test
public void nullSessionRegistrationNegativeTest() {
- thrown.expect(NullPointerException.class);
- connectorProvider.onSessionInitiated(null);
+ this.thrown.expect(NullPointerException.class);
+ this.connectorProvider.onSessionInitiated(null);
}
/**
@Test
public void withoutSchemaServiceRegistrationNegativeTest() {
// prepare conditions
- when(mockSession.getService(SchemaService.class)).thenReturn(null);
+ when(this.mockSession.getService(SchemaService.class)).thenReturn(null);
// test
- thrown.expect(NullPointerException.class);
- connectorProvider.onSessionInitiated(mockSession);
+ this.thrown.expect(NullPointerException.class);
+ this.connectorProvider.onSessionInitiated(this.mockSession);
// verify interaction
- verify(mockSession, times(1)).getService(SchemaService.class);
+ verify(this.mockSession, times(1)).getService(SchemaService.class);
}
/**
*/
@Test
public void closeNotOpenTest() throws Exception {
- connectorProvider.close();
+ this.connectorProvider.close();
}
/**
@Test
public void closeOpenTest() throws Exception {
// prepare conditions
- when(mockSession.getService(SchemaService.class)).thenReturn(mockSchemaService);
- when(mockSession.getService(DOMMountPointService.class)).thenReturn(mockMountPointService);
- when(mockSchemaService.registerSchemaContextListener(Mockito.any(SchemaContextHandler.class)))
- .thenReturn(mockRegistration);
+ when(this.mockSession.getService(SchemaService.class)).thenReturn(this.mockSchemaService);
+ when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(this.mockMountPointService);
+ when(this.mockSchemaService.registerSchemaContextListener(Mockito.any(SchemaContextHandler.class)))
+ .thenReturn(this.mockRegistration);
// register
- connectorProvider.onSessionInitiated(mockSession);
+ this.connectorProvider.onSessionInitiated(this.mockSession);
// close registration
- connectorProvider.close();
+ this.connectorProvider.close();
// verify interaction
- verify(mockRegistration, times(1)).close();
+ verify(this.mockRegistration, times(1)).close();
}
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
+import org.opendaylight.restconf.common.handlers.impl.SchemaContextHandlerImpl;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
/**
* Tests for handling {@link SchemaContext}
@Before
public void setup() throws Exception {
- schemaContextHandler = new SchemaContextHandlerImpl();
+ this.schemaContextHandler = new SchemaContextHandlerImpl();
- schemaContext = TestRestconfUtils.loadSchemaContext(PATH_FOR_ACTUAL_SCHEMA_CONTEXT);
- schemaContextHandler.onGlobalContextUpdated(schemaContext);
+ this.schemaContext = TestRestconfUtils.loadSchemaContext(PATH_FOR_ACTUAL_SCHEMA_CONTEXT);
+ this.schemaContextHandler.onGlobalContextUpdated(this.schemaContext);
}
/**
*/
@Test
public void schemaContextHandlerImplInitTest() {
- assertNotNull("Handler should be created and not null", schemaContextHandler);
+ assertNotNull("Handler should be created and not null", this.schemaContextHandler);
}
/**
@Test
public void getSchemaContextTest() {
assertEquals("SchemaContextHandler should has reference to actual SchemaContext",
- schemaContext, schemaContextHandler.getSchemaContext());
+ this.schemaContext, this.schemaContextHandler.getSchemaContext());
}
/**
@Test
public void onGlobalContextUpdateTest() throws Exception {
// create new SchemaContext and update SchemaContextHandler
- SchemaContext newSchemaContext = TestRestconfUtils.loadSchemaContext(PATH_FOR_NEW_SCHEMA_CONTEXT);
- schemaContextHandler.onGlobalContextUpdated(newSchemaContext);
+ final SchemaContext newSchemaContext = TestRestconfUtils.loadSchemaContext(PATH_FOR_NEW_SCHEMA_CONTEXT);
+ this.schemaContextHandler.onGlobalContextUpdated(newSchemaContext);
assertNotEquals("SchemaContextHandler should not has reference to old SchemaContext",
- schemaContext, schemaContextHandler.getSchemaContext());
+ this.schemaContext, this.schemaContextHandler.getSchemaContext());
assertEquals("SchemaContextHandler should has reference to new SchemaContext",
- newSchemaContext, schemaContextHandler.getSchemaContext());
+ newSchemaContext, this.schemaContextHandler.getSchemaContext());
}
}
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
-
import com.google.common.collect.ImmutableClassToInstanceMap;
import java.util.HashMap;
import org.junit.Before;
import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext;
import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
-import org.opendaylight.restconf.rest.api.services.schema.RestconfSchemaService;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler;
+import org.opendaylight.restconf.rest.services.api.RestconfSchemaService;
+import org.opendaylight.restconf.rest.services.impl.RestconfSchemaServiceImpl;
import org.opendaylight.restconf.utils.RestconfConstants;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
- schemaContext = TestRestconfUtils.loadSchemaContext("/modules");
- schemaContextBehindMountPoint = TestRestconfUtils.loadSchemaContext("/modules/modules-behind-mount-point");
- schemaContextWithMountPoints = TestRestconfUtils.loadSchemaContext("/modules/mount-points");
+ this.schemaContext = TestRestconfUtils.loadSchemaContext("/modules");
+ this.schemaContextBehindMountPoint = TestRestconfUtils.loadSchemaContext("/modules/modules-behind-mount-point");
+ this.schemaContextWithMountPoints = TestRestconfUtils.loadSchemaContext("/modules/mount-points");
// create and register mount points
- mountPoint = SimpleDOMMountPoint.create(
+ this.mountPoint = SimpleDOMMountPoint.create(
YangInstanceIdentifier.of(QName.create("mount:point:1", "2016-01-01", "cont")),
ImmutableClassToInstanceMap.copyOf(new HashMap<>()),
- schemaContextBehindMountPoint
+ this.schemaContextBehindMountPoint
);
- mountPointWithNullSchemaContext = SimpleDOMMountPoint.create(
+ this.mountPointWithNullSchemaContext = SimpleDOMMountPoint.create(
YangInstanceIdentifier.of(QName.create("mount:point:2", "2016-01-01", "cont")),
ImmutableClassToInstanceMap.copyOf(new HashMap<>()),
null
);
- mountPointService = new DOMMountPointServiceImpl();
- ((DOMMountPointServiceImpl) mountPointService).registerMountPoint(mountPoint);
- ((DOMMountPointServiceImpl) mountPointService).registerMountPoint(mountPointWithNullSchemaContext);
- when(mockMountPointHandler.getDOMMountPointService()).thenReturn(mountPointService);
+ this.mountPointService = new DOMMountPointServiceImpl();
+ ((DOMMountPointServiceImpl) this.mountPointService).registerMountPoint(this.mountPoint);
+ ((DOMMountPointServiceImpl) this.mountPointService).registerMountPoint(this.mountPointWithNullSchemaContext);
+ when(this.mockMountPointHandler.getDOMMountPointService()).thenReturn(this.mountPointService);
- schemaService = new RestconfSchemaServiceImpl(mockContextHandler, mockMountPointHandler);
+ this.schemaService = new RestconfSchemaServiceImpl(this.mockContextHandler, this.mockMountPointHandler);
}
/**
*/
@Test
public void schemaServiceImplInitTest() {
- assertNotNull("Schema service should be initialized and not null", schemaService);
+ assertNotNull("Schema service should be initialized and not null", this.schemaService);
}
/**
@Test
public void getSchemaTest() {
// prepare conditions - return not-mount point schema context
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContext);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext);
// make test
- final SchemaExportContext exportContext = schemaService.getSchema(TEST_MODULE);
+ final SchemaExportContext exportContext = this.schemaService.getSchema(TEST_MODULE);
// verify
assertNotNull("Export context should not be null", exportContext);
@Test
public void getSchemaForNotExistingModuleTest() {
// prepare conditions - return not-mount point schema context
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContext);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext);
// make test
- final SchemaExportContext exportContext = schemaService.getSchema(NOT_EXISTING_MODULE);
+ final SchemaExportContext exportContext = this.schemaService.getSchema(NOT_EXISTING_MODULE);
// verify
assertNotNull("Export context should not be null", exportContext);
@Test
public void getSchemaMountPointTest() {
// prepare conditions - return schema context with mount points
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContextWithMountPoints);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints);
// make test
- final SchemaExportContext exportContext = schemaService.getSchema(MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT);
+ final SchemaExportContext exportContext = this.schemaService.getSchema(MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT);
// verify
assertNotNull("Export context should not be null", exportContext);
@Test
public void getSchemaForNotExistingModuleMountPointTest() {
// prepare conditions - return schema context with mount points
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContextWithMountPoints);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints);
// make test
- final SchemaExportContext exportContext = schemaService.getSchema(MOUNT_POINT + NOT_EXISTING_MODULE);
+ final SchemaExportContext exportContext = this.schemaService.getSchema(MOUNT_POINT + NOT_EXISTING_MODULE);
// verify
assertNotNull("Export context should not be null", exportContext);
@Test
public void getSchemaWithNullSchemaContextTest() {
// prepare conditions - returned schema context is null
- when(mockContextHandler.getSchemaContext()).thenReturn(null);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(null);
// make test
- thrown.expect(NullPointerException.class);
- schemaService.getSchema(TEST_MODULE);
+ this.thrown.expect(NullPointerException.class);
+ this.schemaService.getSchema(TEST_MODULE);
}
/**
@Test
public void getSchemaWithNullSchemaContextMountPointTest() {
// prepare conditions - returned schema context for mount points is null
- when(mockContextHandler.getSchemaContext()).thenReturn(null);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(null);
// make test
- thrown.expect(NullPointerException.class);
- schemaService.getSchema(MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT);
+ this.thrown.expect(NullPointerException.class);
+ this.schemaService.getSchema(MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT);
}
/**
@Test
public void getSchemaNullSchemaContextBehindMountPointTest() {
// prepare conditions - return correct schema context for mount points (this is not null)
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContextWithMountPoints);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints);
// make test - call service on mount point with null schema context
- thrown.expect(NullPointerException.class);
+ this.thrown.expect(NullPointerException.class);
// NULL_MOUNT_POINT contains null schema context
- schemaService.getSchema(NULL_MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT);
+ this.schemaService.getSchema(NULL_MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT);
}
/**
@Test
public void getSchemaWithNullIdentifierTest() {
// prepare conditions - return correct schema context
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContext);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext);
// make test
- thrown.expect(NullPointerException.class);
- schemaService.getSchema(null);
+ this.thrown.expect(NullPointerException.class);
+ this.schemaService.getSchema(null);
}
/**
@Test
public void getSchemaWithEmptyIdentifierTest() {
// prepare conditions - return correct schema context
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContext);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext);
// make test and verify
try {
- schemaService.getSchema("");
+ this.schemaService.getSchema("");
fail("Test should fail due to invalid identifier");
- } catch (RestconfDocumentedException e) {
+ } catch (final RestconfDocumentedException e) {
assertEquals(RestconfError.ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
assertEquals(RestconfError.ErrorTag.INVALID_VALUE, e.getErrors().get(0).getErrorTag());
assertEquals(400, e.getErrors().get(0).getErrorTag().getStatusCode());
@Test
public void getSchemaWithEmptyIdentifierMountPointTest() {
// prepare conditions - return correct schema context with mount points
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContextWithMountPoints);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints);
// make test and verify
try {
- schemaService.getSchema(MOUNT_POINT + "");
+ this.schemaService.getSchema(MOUNT_POINT + "");
fail("Test should fail due to invalid identifier");
- } catch (RestconfDocumentedException e) {
+ } catch (final RestconfDocumentedException e) {
assertEquals(RestconfError.ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
assertEquals(RestconfError.ErrorTag.INVALID_VALUE, e.getErrors().get(0).getErrorTag());
assertEquals(400, e.getErrors().get(0).getErrorTag().getStatusCode());
@Test
public void getSchemaWithNotParsableIdentifierTest() {
// prepare conditions - return correct schema context without mount points
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContext);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext);
// make test and verify
try {
- schemaService.getSchema("01_module/2016-01-01");
+ this.schemaService.getSchema("01_module/2016-01-01");
fail("Test should fail due to invalid identifier");
- } catch (RestconfDocumentedException e) {
+ } catch (final RestconfDocumentedException e) {
assertEquals(RestconfError.ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
assertEquals(RestconfError.ErrorTag.INVALID_VALUE, e.getErrors().get(0).getErrorTag());
assertEquals(400, e.getErrors().get(0).getErrorTag().getStatusCode());
@Test
public void getSchemaWithNotParsableIdentifierMountPointTest() {
// prepare conditions - return correct schema context with mount points
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContextWithMountPoints);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints);
// make test and verify
try {
- schemaService.getSchema(MOUNT_POINT + "01_module/2016-01-01");
+ this.schemaService.getSchema(MOUNT_POINT + "01_module/2016-01-01");
fail("Test should fail due to invalid identifier");
- } catch (RestconfDocumentedException e) {
+ } catch (final RestconfDocumentedException e) {
assertEquals(RestconfError.ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
assertEquals(RestconfError.ErrorTag.INVALID_VALUE, e.getErrors().get(0).getErrorTag());
assertEquals(400, e.getErrors().get(0).getErrorTag().getStatusCode());
@Test
public void getSchemaWrongIdentifierTest() {
// prepare conditions - return correct schema context without mount points
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContext);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext);
// make test and verify
try {
- schemaService.getSchema("2014-01-01");
+ this.schemaService.getSchema("2014-01-01");
fail("Test should fail due to invalid identifier");
- } catch (RestconfDocumentedException e) {
+ } catch (final RestconfDocumentedException e) {
assertEquals(RestconfError.ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
assertEquals(RestconfError.ErrorTag.INVALID_VALUE, e.getErrors().get(0).getErrorTag());
assertEquals(400, e.getErrors().get(0).getErrorTag().getStatusCode());
@Test
public void getSchemaWrongIdentifierMountPointTest() {
// prepare conditions - return correct schema context with mount points
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContextWithMountPoints);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints);
// make test and verify
try {
- schemaService.getSchema(MOUNT_POINT + "2014-01-01");
+ this.schemaService.getSchema(MOUNT_POINT + "2014-01-01");
fail("Test should fail due to invalid identifier");
- } catch (RestconfDocumentedException e) {
+ } catch (final RestconfDocumentedException e) {
assertEquals(RestconfError.ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
assertEquals(RestconfError.ErrorTag.INVALID_VALUE, e.getErrors().get(0).getErrorTag());
assertEquals(400, e.getErrors().get(0).getErrorTag().getStatusCode());
@Test
public void getSchemaWithoutRevisionTest() {
// prepare conditions - return correct schema context without mount points
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContext);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContext);
// make test and verify
try {
- schemaService.getSchema("module");
+ this.schemaService.getSchema("module");
fail("Test should fail due to invalid identifier");
- } catch (RestconfDocumentedException e) {
+ } catch (final RestconfDocumentedException e) {
assertEquals(RestconfError.ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
assertEquals(RestconfError.ErrorTag.INVALID_VALUE, e.getErrors().get(0).getErrorTag());
assertEquals(400, e.getErrors().get(0).getErrorTag().getStatusCode());
@Test
public void getSchemaWithoutRevisionMountPointTest() {
// prepare conditions - return correct schema context with mount points
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContextWithMountPoints);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints);
// make test and verify
try {
- schemaService.getSchema(MOUNT_POINT + "module");
+ this.schemaService.getSchema(MOUNT_POINT + "module");
fail("Test should fail due to invalid identifier");
- } catch (RestconfDocumentedException e) {
+ } catch (final RestconfDocumentedException e) {
assertEquals(RestconfError.ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
assertEquals(RestconfError.ErrorTag.INVALID_VALUE, e.getErrors().get(0).getErrorTag());
assertEquals(400, e.getErrors().get(0).getErrorTag().getStatusCode());
@Test
public void getSchemaContextWithNotExistingMountPointTest() {
// prepare conditions - return schema context with mount points
- when(mockContextHandler.getSchemaContext()).thenReturn(schemaContextWithMountPoints);
+ when(this.mockContextHandler.getSchemaContext()).thenReturn(this.schemaContextWithMountPoints);
// make test
- thrown.expect(IllegalArgumentException.class);
- schemaService.getSchema(NOT_EXISTING_MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT);
+ this.thrown.expect(IllegalArgumentException.class);
+ this.schemaService.getSchema(NOT_EXISTING_MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT);
}
}
import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
import static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.EMPTY;
-import static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import java.util.AbstractMap;
import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
import org.opendaylight.netconf.sal.streams.listeners.Notificator;
import org.opendaylight.restconf.Draft11;
-import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
-import org.opendaylight.restconf.rest.api.services.RestconfStreamsService;
+import org.opendaylight.restconf.common.handlers.api.SchemaContextHandler;
+import org.opendaylight.restconf.rest.services.api.RestconfStreamsService;
+import org.opendaylight.restconf.rest.services.impl.RestconfStreamsServiceImpl;
import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeConstants;
import org.opendaylight.restconf.utils.mapping.RestconfMappingStreamConstants;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
*/
@Test
public void restconfStreamsServiceImplInitTest() {
- assertNotNull("Streams service should be initialized and not null", streamsService);
+ assertNotNull("Streams service should be initialized and not null", this.streamsService);
}
/**
@Test
public void getAvailableStreamsTest() throws Exception {
// prepare conditions - get correct Restconf module
- when(contextHandler.getSchemaContext()).thenReturn(mockSchemaContext);
- when(mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
+ when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext);
+ when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
.getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
.thenReturn(getTestingRestconfModule("ietf-restconf"));
// make test
- final NormalizedNodeContext nodeContext = streamsService.getAvailableStreams(null);
+ final NormalizedNodeContext nodeContext = this.streamsService.getAvailableStreams(null);
// verify loaded streams
assertNotNull("Normalized node context should not be null", nodeContext);
@Test
public void getAvailableStreamsNullSchemaContextNegativeTest() {
// prepare conditions - returned SchemaContext is null
- when(contextHandler.getSchemaContext()).thenReturn(null);
+ when(this.contextHandler.getSchemaContext()).thenReturn(null);
// make test
- thrown.expect(NullPointerException.class);
- streamsService.getAvailableStreams(null);
+ this.thrown.expect(NullPointerException.class);
+ this.streamsService.getAvailableStreams(null);
}
/**
@Test
public void getAvailableStreamsMissingRestconfModuleNegativeTest() {
// prepare conditions - get null Restconf module
- when(contextHandler.getSchemaContext()).thenReturn(mockSchemaContext);
- when(mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
+ when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext);
+ when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
.getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision())).thenReturn(null);
// make test
- thrown.expect(NullPointerException.class);
- streamsService.getAvailableStreams(null);
+ this.thrown.expect(NullPointerException.class);
+ this.streamsService.getAvailableStreams(null);
}
/**
@Test
public void getAvailableStreamsMissingListStreamNegativeTest() {
// prepare conditions - get Restconf module with missing list stream
- when(contextHandler.getSchemaContext()).thenReturn(mockSchemaContext);
- when(mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
+ when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext);
+ when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
.getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
.thenReturn(getTestingRestconfModule("restconf-module-with-missing-list-stream"));
// make test and verify
try {
- streamsService.getAvailableStreams(null);
+ this.streamsService.getAvailableStreams(null);
fail("Test is expected to fail due to missing list stream");
} catch (final RestconfDocumentedException e) {
assertEquals("Error type is not correct",
@Test
public void getAvailableStreamsMissingContainerStreamsNegativeTest() {
// prepare conditions - get Restconf module with missing container streams
- when(contextHandler.getSchemaContext()).thenReturn(mockSchemaContext);
- when(mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
+ when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext);
+ when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
.getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
.thenReturn(getTestingRestconfModule("restconf-module-with-missing-container-streams"));
// make test and verify
try {
- streamsService.getAvailableStreams(null);
+ this.streamsService.getAvailableStreams(null);
fail("Test is expected to fail due to missing container streams");
} catch (final RestconfDocumentedException e) {
assertEquals("Error type is not correct",
@Test
public void getAvailableStreamsIllegalListStreamNegativeTest() {
// prepare conditions - get Restconf module with illegal list stream
- when(contextHandler.getSchemaContext()).thenReturn(mockSchemaContext);
- when(mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
+ when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext);
+ when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
.getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
.thenReturn(getTestingRestconfModule("restconf-module-with-illegal-list-stream"));
// make test
- thrown.expect(IllegalStateException.class);
- streamsService.getAvailableStreams(null);
+ this.thrown.expect(IllegalStateException.class);
+ this.streamsService.getAvailableStreams(null);
}
/**
@Test
public void getAvailableStreamsIllegalContainerStreamsNegativeTest() {
// prepare conditions - get Restconf module with illegal container streams
- when(contextHandler.getSchemaContext()).thenReturn(mockSchemaContext);
- when(mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
+ when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext);
+ when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
.getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
.thenReturn(getTestingRestconfModule("restconf-module-with-illegal-container-streams"));
// make test
- thrown.expect(IllegalStateException.class);
- streamsService.getAvailableStreams(null);
+ this.thrown.expect(IllegalStateException.class);
+ this.streamsService.getAvailableStreams(null);
}
/**
@Test
public void getAvailableStreamsIllegalLeafDescriptionNegativeTest() {
// prepare conditions - get Restconf module with illegal leaf description in list stream
- when(contextHandler.getSchemaContext()).thenReturn(mockSchemaContext);
- when(mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
+ when(this.contextHandler.getSchemaContext()).thenReturn(this.mockSchemaContext);
+ when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
.getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
.thenReturn(getTestingRestconfModule("restconf-module-with-illegal-leaf-description"));
// make test
- thrown.expect(IllegalStateException.class);
- streamsService.getAvailableStreams(null);
+ this.thrown.expect(IllegalStateException.class);
+ this.streamsService.getAvailableStreams(null);
}
/**
* @return Restconf module
*/
private Module getTestingRestconfModule(final String s) {
- return schemaContext.findModuleByName(s, Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
+ return this.schemaContext.findModuleByName(s, Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
}
/**