@Test public void rewriteWithoutFeature() throws Exception { // If the opensocial-data feature is present, the rewrite is a no-op setupGadget(XML_WITHOUT_FEATURE); control.replay(); rewriter.rewrite(gadget, content); control.verify(); }
@Test public void rewriteWithoutPipeline() throws Exception { setupGadget(XML_WITHOUT_PIPELINE); control.replay(); // If there are no pipeline elements, the rewrite is a no-op rewriter.rewrite(gadget, content); control.verify(); }
@Test public void rewriteWithoutFeature() throws Exception { // If the opensocial-data feature is present, the rewrite is a no-op setupGadget(XML_WITHOUT_FEATURE); control.replay(); rewriter.rewrite(gadget, content); control.verify(); }
@Test public void rewriteWithoutPipeline() throws Exception { setupGadget(XML_WITHOUT_PIPELINE); control.replay(); // If there are no pipeline elements, the rewrite is a no-op rewriter.rewrite(gadget, content); control.verify(); }
@Test public void rewriteWithoutPipeline() throws Exception { setupGadget(XML_WITHOUT_PIPELINE); control.replay(); // If there are no pipeline elements, the rewrite is a no-op rewriter.rewrite(gadget, content); control.verify(); }
@Test public void rewriteWithoutFeature() throws Exception { // If the opensocial-data feature is present, the rewrite is a no-op setupGadget(XML_WITHOUT_FEATURE); control.replay(); rewriter.rewrite(gadget, content); control.verify(); }
@Test public void rewriteWithBlockedBatch() throws Exception { setupGadget(getGadgetXml(BLOCKED_FIRST_BATCH_CONTENT)); // Expect a batch with no content expect( preloader.createPreloadTasks(same(gadget.getContext()), eqBatch(0, 0))) .andReturn(ImmutableList.<Callable<PreloadedData>>of()); control.replay(); rewriter.rewrite(gadget, content); control.verify(); // Check there is no DataContext inserted assertFalse("DataContext write shouldn't be present", content.getContent().indexOf( "DataContext.putDataSet(") > 0); // And the os-data elements should be present assertTrue("os-data was deleted", content.getContent().indexOf("type=\"text/os-data\"") > 0); }
@Test public void rewriteWithBlockedBatch() throws Exception { setupGadget(getGadgetXml(BLOCKED_FIRST_BATCH_CONTENT)); // Expect a batch with no content expect( preloader.createPreloadTasks(same(gadget.getContext()), eqBatch(0, 0))) .andReturn(ImmutableList.<Callable<PreloadedData>>of()); control.replay(); rewriter.rewrite(gadget, content); control.verify(); // Check there is no DataContext inserted assertFalse("DataContext write shouldn't be present", content.getContent().indexOf( "DataContext.putDataSet(") > 0); // And the os-data elements should be present assertTrue("os-data was deleted", content.getContent().indexOf("type=\"text/os-data\"") > 0); }
@Test public void rewriteWithBlockedBatch() throws Exception { setupGadget(getGadgetXml(BLOCKED_FIRST_BATCH_CONTENT)); // Expect a batch with no content expect( preloader.createPreloadTasks(same(gadget.getContext()), eqBatch(0, 0))) .andReturn(ImmutableList.<Callable<PreloadedData>>of()); control.replay(); rewriter.rewrite(gadget, content); control.verify(); // Check there is no DataContext inserted assertFalse("DataContext write shouldn't be present", content.getContent().indexOf( "DataContext.putDataSet(") > 0); // And the os-data elements should be present assertTrue("os-data was deleted", content.getContent().indexOf("type=\"text/os-data\"") > 0); }
@Test public void rewrite() throws Exception { setupGadget(getGadgetXml(CONTENT)); Capture<PipelinedData.Batch> batchCapture = new Capture<PipelinedData.Batch>(); // Dummy return results (the "real" return would have two values) Callable<PreloadedData> callable = createPreloadTask( "key", "{result: {foo: 'bar'}}"); // One batch with 1 each HTTP and Social preload expect(preloader.createPreloadTasks(same(gadget.getContext()), and(eqBatch(1, 1), capture(batchCapture)))) .andReturn(ImmutableList.of(callable)); control.replay(); rewriter.rewrite(gadget, content); // Verify the data set is injected, and the os-data was deleted assertTrue("Script not inserted", content.getContent().contains("DataContext.putDataSet(\"key\",{\"foo\":\"bar\"})")); assertFalse("os-data wasn't deleted", content.getContent().contains("type=\"text/os-data\"")); assertTrue(batchCapture.getValue().getPreloads().containsKey("me")); assertTrue(batchCapture.getValue().getPreloads().containsKey("json")); assertFalse(gadget.getDirectFeatureDeps().contains("opensocial-data")); assertTrue(gadget.getDirectFeatureDeps().contains("opensocial-data-context")); control.verify(); } @Test
@Test public void rewrite() throws Exception { setupGadget(getGadgetXml(CONTENT)); Capture<PipelinedData.Batch> batchCapture = new Capture<PipelinedData.Batch>(); // Dummy return results (the "real" return would have two values) Callable<PreloadedData> callable = createPreloadTask( "key", "{result: {foo: 'bar'}}"); // One batch with 1 each HTTP and Social preload expect(preloader.createPreloadTasks(same(gadget.getContext()), and(eqBatch(1, 1), capture(batchCapture)))) .andReturn(ImmutableList.of(callable)); control.replay(); rewriter.rewrite(gadget, content); // Verify the data set is injected, and the os-data was deleted assertTrue("Script not inserted", content.getContent().contains("DataContext.putDataSet(\"key\",{\"foo\":\"bar\"})")); assertFalse("os-data wasn't deleted", content.getContent().contains("type=\"text/os-data\"")); assertTrue(batchCapture.getValue().getPreloads().containsKey("me")); assertTrue(batchCapture.getValue().getPreloads().containsKey("json")); assertFalse(gadget.getDirectFeatureDeps().contains("opensocial-data")); assertTrue(gadget.getDirectFeatureDeps().contains("opensocial-data-context")); control.verify(); } @Test
@Test public void rewrite() throws Exception { setupGadget(getGadgetXml(CONTENT)); Capture<PipelinedData.Batch> batchCapture = new Capture<PipelinedData.Batch>(); // Dummy return results (the "real" return would have two values) Callable<PreloadedData> callable = createPreloadTask( "key", "{result: {foo: 'bar'}}"); // One batch with 1 each HTTP and Social preload expect(preloader.createPreloadTasks(same(gadget.getContext()), and(eqBatch(1, 1), capture(batchCapture)))) .andReturn(ImmutableList.of(callable)); control.replay(); rewriter.rewrite(gadget, content); // Verify the data set is injected, and the os-data was deleted assertTrue("Script not inserted", content.getContent().contains("DataContext.putDataSet(\"key\",{\"foo\":\"bar\"})")); assertFalse("os-data wasn't deleted", content.getContent().contains("type=\"text/os-data\"")); assertTrue(batchCapture.getValue().getPreloads().containsKey("me")); assertTrue(batchCapture.getValue().getPreloads().containsKey("json")); assertFalse(gadget.getDirectFeatureDeps().contains("opensocial-data")); assertTrue(gadget.getDirectFeatureDeps().contains("opensocial-data-context")); control.verify(); } @Test