### Question:
DefaultGadgetSource implements GadgetSource { @Override public List<Gadget> getGadgets(String source, MacroTransformationContext context) throws Exception { DocumentReference sourceDocRef = getSourceDocumentReference(source); if (sourceDocRef == null) { return new ArrayList<>(); } XWikiContext xContext = getXWikiContext(); XWiki xWiki = xContext.getWiki(); XWikiDocument sourceDoc = xWiki.getDocument(sourceDocRef, xContext); DocumentReference gadgetsClass = currentReferenceEntityResolver.resolve(GADGET_CLASS); List<BaseObject> gadgetObjects = sourceDoc.getXObjects(gadgetsClass); if (gadgetObjects == null || gadgetObjects.isEmpty()) { return new ArrayList<>(); } this.progress.startStep(this, "dashboard.progress.prepareGadgets", "Prepare gadgets for document [{}] ({})", sourceDocRef, gadgetObjects.size()); this.progress.pushLevelProgress(gadgetObjects.size(), this); try { return prepareGadgets(gadgetObjects, sourceDoc.getSyntax(), context); } finally { this.progress.popLevelProgress(this); this.progress.endStep(this); } }  @Override List<Gadget> getGadgets(String source, MacroTransformationContext context); @Override List<Block> getDashboardSourceMetadata(String source, MacroTransformationContext context); @Override boolean isEditing();  }### Answer:
@Test public void getGadgets() throws Exception { assertEquals(new ArrayList<>(), this.defaultGadgetSource.getGadgets(testSource, macroTransformationContext)); BaseObject gadgetObject1 = mock(BaseObject.class); when(xWikiDocument.getXObjects(gadgetClassReference)).thenReturn(Collections.singletonList(gadgetObject1)); when(gadgetObject1.getOwnerDocument()).thenReturn(ownerDocument); when(gadgetObject1.getStringValue("title")).thenReturn("Gadget 1"); when(gadgetObject1.getLargeStringValue("content")).thenReturn("Some content"); when(gadgetObject1.getStringValue("position")).thenReturn("0"); when(gadgetObject1.getNumber()).thenReturn(42); List<Gadget> gadgets = this.defaultGadgetSource.getGadgets(testSource, macroTransformationContext); assertEquals(1, gadgets.size()); Gadget gadget = gadgets.get(0); assertEquals("Gadget 1", gadget.getTitle().get(0).toString()); assertEquals("Some content", gadget.getContent().get(0).toString()); assertEquals("42", gadget.getId()); }