@Test public void getEnabledElements() throws ComponentLookupException { UIExtensionManager m = mock(UIExtensionManager.class); UIExtension ex = mock(UIExtension.class); UIExtensionFilter filter = mock(UIExtensionFilter.class, "sortByParameter"); UIExtensionFilter realFilter = new SortByParameterFilter(); when(ex.getId()).thenReturn("org.phenotips.patientSheet.section.patient-info"); RecordSection s = new UIXRecordSection(ex, m, filter); Map<String, String> params; List<UIExtension> fields = new LinkedList<>(); ex = mock(UIExtension.class); params = new HashMap<>(); params.put("enabled", ""); params.put(ORDER, "2"); when(ex.getParameters()).thenReturn(params); when(ex.getId()).thenReturn("1"); fields.add(ex); ex = mock(UIExtension.class); params = new HashMap<>(); params.put("enabled", "true"); params.put(ORDER, "1"); when(ex.getParameters()).thenReturn(params); when(ex.getId()).thenReturn("0"); fields.add(ex); ex = mock(UIExtension.class); params = new HashMap<>(); params.put("enabled", "false"); params.put(ORDER, "3"); when(ex.getParameters()).thenReturn(params); when(ex.getId()).thenReturn("invalid"); fields.add(ex); ex = mock(UIExtension.class); params = new HashMap<>(); when(ex.getParameters()).thenReturn(params); when(ex.getId()).thenReturn("3"); fields.add(ex); ex = mock(UIExtension.class); params = new HashMap<>(); params.put(ORDER, "4"); when(ex.getParameters()).thenReturn(params); when(ex.getId()).thenReturn("2"); fields.add(ex); when(m.get("org.phenotips.patientSheet.section.patient-info")).thenReturn(fields); List<UIExtension> sorted = realFilter.filter(fields, ORDER); when(filter.filter(fields, ORDER)).thenReturn(sorted); List<RecordElement> result = s.getEnabledElements(); Assert.assertEquals(4, result.size()); for (int i = 0; i < 4; ++i) { Assert.assertEquals(String.valueOf(i), result.get(i).getExtension().getId()); } }
@Override public List<RecordElement> getEnabledElements() { List<RecordElement> result = new LinkedList<>(); for (RecordElement element : getAllElements()) { if (element.isEnabled()) { result.add(element); } } return Collections.unmodifiableList(result); }
UIXRecordSection implements RecordSection { @Override public List<RecordElement> getEnabledElements() { List<RecordElement> result = new LinkedList<>(); for (RecordElement element : getAllElements()) { if (element.isEnabled()) { result.add(element); } } return Collections.unmodifiableList(result); } }
UIXRecordSection implements RecordSection { @Override public List<RecordElement> getEnabledElements() { List<RecordElement> result = new LinkedList<>(); for (RecordElement element : getAllElements()) { if (element.isEnabled()) { result.add(element); } } return Collections.unmodifiableList(result); } UIXRecordSection(UIExtension extension, UIExtensionManager uixManager, UIExtensionFilter orderFilter); }
UIXRecordSection implements RecordSection { @Override public List<RecordElement> getEnabledElements() { List<RecordElement> result = new LinkedList<>(); for (RecordElement element : getAllElements()) { if (element.isEnabled()) { result.add(element); } } return Collections.unmodifiableList(result); } UIXRecordSection(UIExtension extension, UIExtensionManager uixManager, UIExtensionFilter orderFilter); @Override UIExtension getExtension(); @Override String getName(); @Override boolean isEnabled(); @Override void setEnabled(boolean enabled); @Override boolean isExpandedByDefault(); @Override void setExpandedByDefault(boolean expanded); @Override List<RecordElement> getAllElements(); @Override List<RecordElement> getEnabledElements(); @Override void setElements(List<RecordElement> elements); @Override String toString(); }
UIXRecordSection implements RecordSection { @Override public List<RecordElement> getEnabledElements() { List<RecordElement> result = new LinkedList<>(); for (RecordElement element : getAllElements()) { if (element.isEnabled()) { result.add(element); } } return Collections.unmodifiableList(result); } UIXRecordSection(UIExtension extension, UIExtensionManager uixManager, UIExtensionFilter orderFilter); @Override UIExtension getExtension(); @Override String getName(); @Override boolean isEnabled(); @Override void setEnabled(boolean enabled); @Override boolean isExpandedByDefault(); @Override void setExpandedByDefault(boolean expanded); @Override List<RecordElement> getAllElements(); @Override List<RecordElement> getEnabledElements(); @Override void setElements(List<RecordElement> elements); @Override String toString();  }