@Before public void inContext() { updatedFiles = newArrayList(); core = new DefaultInfinitestCore(mock(TestRunner.class), new ControlledEventQueue()); testDetector = mock(TestDetector.class); when(testDetector.getCurrentTests()).thenReturn(Collections.<String>emptySet()); core.setTestDetector(testDetector); }
private <T> Collection<T> random(Store<T> s, int rows, int sampleSize) { if (rows > 0) { Set<T> ret = new HashSet<T>(); Random r = new Random(); for (int i = 0; i < sampleSize; i++) { try { int rand = r.nextInt(rows); if (rand != 0) { T t; try { Method lazy = s.getClass().getDeclaredMethod("lazyGet", Long.TYPE); t = (T) lazy.invoke(s, new Long(rand)); } catch (NoSuchMethodException e) { System.out.println("WARN:: Unable to lazily get object. Using full get."); t = s.get(Integer.valueOf(rand).longValue()); } catch (InvocationTargetException e) { System.out.println("WARN:: Unable to lazily get object. Using full get."); t = s.get(Integer.valueOf(rand).longValue()); } catch (IllegalAccessException e) { System.out.println("WARN:: Unable to lazily get object. Using full get."); t = s.get(Integer.valueOf(rand).longValue()); } if (t != null) { ret.add(t); } } } catch (IOException e) { System.out.println("ERROR:: could not get random object from store"); } } return ret; } else { return Collections.emptySet(); } }