ProjectResourcePanel extends BasicResolvablePanel<Resolvable<?, ?>> implements RestrictedComponent { protected Triplet computeProgressBars(Resolvable<?, ?> resolvable) { int greenWidth = resolvable.getPercentComplete(); int yellowWidth = 0; if (resolvable instanceof PropertyFileDescriptor) { PropertyFileDescriptor descriptor = (PropertyFileDescriptor) resolvable; int keys = descriptor.getMaster() == null ? descriptor.getKeys() : descriptor.getMaster().getKeys(); if(keys>0) { EList<Review> reviews = descriptor.getReviews(); int activeReviews = 0; for (Review review : reviews) { if(review.getState()==ReviewState.OPEN || review.getState()==ReviewState.REOPENED) activeReviews++; } yellowWidth = (int) (activeReviews*100/(double)keys); greenWidth -= yellowWidth; } } return new Triplet(greenWidth, yellowWidth); } ProjectResourcePanel(Resolvable<?, ?> object, PageParameters parameters); @Override void renderHead(IHeaderResponse response); @Override String getRequiredPermission();  }
@SuppressWarnings("rawtypes") @Test public void computeProgressBars() { Resolvable mock = mock(Resolvable.class); when(mock.getPercentComplete()).thenReturn(15); Triplet result = fixture.computeProgressBars(mock); assertEquals(15, result.getSuccess()); assertEquals(0, result.getWarning()); assertEquals(0, result.getDanger()); }