ScreenService extends BasicService implements OwnerAPISupport<Screen> { @Override @POST @Path("/screens/{screenId}/owners") @Consumes(MediaType.APPLICATION_JSON) public Screen addOwners(@PathParam("screenId") long screenId, Owner[] ownerData) { Screen existingScreen = getExistingScreen(screenId, true); doAddOwners(existingScreen, ownerData); if (existingScreen.getPlaylist() != null) { existingScreen.getPlaylist().expand(); } return ScreenDAO.save(existingScreen); }  @GET @Path("/screens") @Produces(MediaType.APPLICATION_JSON) List<Screen> getScreens(@QueryParam("userId") String userId); @GET @Path("/onboardings") @Produces(MediaType.APPLICATION_JSON) List<Screen> getOnboardings(); @GET @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) Screen getScreen(@PathParam("id") long screenId,
			@DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics,
			@DefaultValue("false") @QueryParam("live") boolean live); @GET @Path("/screens/bykey/{key}") @Produces(MediaType.APPLICATION_JSON) Screen getScreenByKey(@PathParam("key") String key,
			@DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics,
			@DefaultValue("false") @QueryParam("live") boolean live,
			@DefaultValue("false") @QueryParam("autoOnboard") boolean doOnboarding,
			@QueryParam("owner") String requestedOwner); @POST @Path("/screens") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Screen createScreen(Screen screen); @PUT @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) Screen updateScreen(@PathParam("id") long screenId, Screen screenData); @PUT @Path("/screens/{id}/statistics") @Produces(MediaType.APPLICATION_JSON) Screen updateScreenStatstics(@PathParam("id") long screenId, Screen screenData); @GET @Path("/screens/{id}/health") @Produces(MediaType.APPLICATION_JSON) Screen.AliveState getScreenHealth(@PathParam("id") long screenId); @GET @Path("/screens/{id}/events") @Produces(MediaType.APPLICATION_JSON) List<EventHistory> getScreenEvents(@PathParam("id") long screenId); @GET @Path("/screens/{id}/eventsperhour") @Produces(MediaType.APPLICATION_JSON) List<BasicNameValuePair> getScreenEventsPerHour(@PathParam("id") long screenId); @GET @Path("/screens/{id}/control") @Produces(MediaType.APPLICATION_JSON) Integer getRemoteKey(@PathParam("id") long screenId); @PUT @Path("/screens/{id}/control/{key}") @Produces(MediaType.APPLICATION_JSON) Screen remoteControlScreen(@PathParam("id") long screenId, Screen screenData, @PathParam("key") int key); @POST @Path("/screens/{id}/copy") @Consumes(MediaType.APPLICATION_JSON) Screen copyScreen(@PathParam("id") long screenId, Screen newScreen); @PUT @Path("/screens/{id}/requestedOwner") @Produces(MediaType.APPLICATION_JSON) Screen updateRequestedOwner(@PathParam("id") long screenId, Screen screenData); @POST @Path("/screens/{id}/onboard") @Produces(MediaType.APPLICATION_JSON) Screen onboardScreen(@PathParam("id") long screenId); @POST @Path("/claim/{key}") @Produces(MediaType.APPLICATION_JSON) Screen claimScreen(@PathParam("key") String key, @DefaultValue("0") @QueryParam("screenId") long screenId); @DELETE @Path("/screens/{screenId}") Response deleteScreen(@PathParam("screenId") long screenId); @Override @POST @Path("/screens/{screenId}/owners") @Consumes(MediaType.APPLICATION_JSON) Screen addOwners(@PathParam("screenId") long screenId, Owner[] ownerData); @Override @DELETE @Path("/screens/{screenId}/owners/{ownerId}") @Produces(MediaType.APPLICATION_JSON) Screen deleteOwner(@PathParam("screenId") long screenId, @PathParam("ownerId") long ownerId); @POST @Path("/screenkey/{key}/appliancestart") @Consumes(MediaType.APPLICATION_JSON) Response registerApplianceStart(@PathParam("key") String key, ApplianceInfo logContent);  }
@Test public void testAddOwners() throws Exception { Screen screen = new Screen("s1"); screen = screenService.createScreen(screen); assertEquals(1, screenService.getScreen(screen.getId(), true, false).getOwners().size()); screenService.addOwners(screen.getId(), new Owner[] { new Owner(new User("i1")) }); assertEquals(2, screenService.getScreen(screen.getId(), true, false).getOwners().size()); List<Owner> owners = screenService.getScreen(screen.getId(), true, false).getOwners(); assertEquals("i1", owners.get(1).getUser().getUserId()); screenService.addOwners(screen.getId(), new Owner[] { new Owner(new User("i2")) }); assertEquals(3, screenService.getScreen(screen.getId(), true, false).getOwners().size()); }