TemplateResource { protected void hoistNewTemplateToTopLevel(String newTemplateId, ItemManager itemMan) { boolean success = itemMan.hoistItemToTopLevel(newTemplateId); if (!success) { throw new PersistenceException(String.format( "Could not hoist item with ID '%s'", newTemplateId )); } }  @GET @Path("/item/{id}") @Produces(MediaType.APPLICATION_JSON) Response getTemplate(@PathParam("id") String id, @Context Request request); Response instantiateTemplate(Document metadataXml, ParsedMetadata parsedMetadata, String id, String content); @POST @Path("/storm") @Produces(MediaType.APPLICATION_JSON) @ConfiguredRolesAllowed(ConfiguredRolesAllowedDynamicFeature.CCH_ADMIN_USER_PROP) Response instantiateStormTemplate(
			@FormDataParam("layerId") String layerId,
			@FormDataParam("activeStorm") String active,
			@FormDataParam("alias") String alias,
			@FormDataParam("copyType") String copyType,
			@FormDataParam("copyVal") String copyVal,
			@FormDataParam("trackId") String trackId,
			@FormDataParam("file") String metadataFile);  }
@Test(expected = PersistenceException.class) public void testThatFailedItemHoistingThrowsException() { String id = "foo"; when(mockItemMan.hoistItemToTopLevel(id)).thenReturn(false); instance.hoistNewTemplateToTopLevel(id, mockItemMan); }
@Test public void testThatSuccessfulItemHoistingThrowsNoException() { String id = "foo"; when(mockItemMan.hoistItemToTopLevel(id)).thenReturn(true); instance.hoistNewTemplateToTopLevel(id, mockItemMan); }