ViewDataMigrationService extends BaseService { @PUT @Path("{originVersion}/{originInstanceName}") public Response migrateData(@PathParam("originVersion") String originViewVersion, @PathParam("originInstanceName") String originInstanceName) throws ViewDataMigrationException { if (!viewRegistry.checkAdmin()) { throw new WebApplicationException(Response.Status.FORBIDDEN); } LOG.info("Data Migration to view instance " + viewName + "/" + viewVersion + "/" + instanceName + " from " + viewName + "/" + originViewVersion + "/" + originInstanceName); ViewInstanceEntity instanceDefinition = viewRegistry.getInstanceDefinition( viewName, viewVersion, instanceName); ViewInstanceEntity originInstanceDefinition = viewRegistry.getInstanceDefinition( viewName, originViewVersion, originInstanceName); getViewDataMigrationUtility().migrateData(instanceDefinition, originInstanceDefinition, false); Response.ResponseBuilder builder = Response.status(Response.Status.OK); return builder.build(); } ViewDataMigrationService(String viewName, String viewVersion, String instanceName); @PUT @Path("{originVersion}/{originInstanceName}") Response migrateData(@PathParam("originVersion") String originViewVersion,
                              @PathParam("originInstanceName") String originInstanceName);  }
@Test public void testServiceMigrateCallNotAdmin() throws Exception { ViewRegistry viewRegistry = createNiceMock(ViewRegistry.class); expect(viewRegistry.checkAdmin()).andReturn(false).anyTimes(); replay(viewRegistry); ViewRegistry.initInstance(viewRegistry); ViewDataMigrationService service = new ViewDataMigrationService(viewName, version1, instanceName); thrown.expect(WebApplicationException.class); service.migrateData(version2, instanceName); }