AggregatorUtil { static public String getCacheBust(IAggregator aggregator) { return getCacheBust(aggregator.getConfig(), aggregator.getOptions()); }  static String getCacheBust(IAggregator aggregator); static String getCacheBust(IConfig config, IOptions options);  }
@Test public void testGetCacheBust() throws Exception { IAggregator mockAggregator = EasyMock.createMock(IAggregator.class); final IConfig mockConfig = EasyMock.createNiceMock(IConfig.class); final IOptions mockOptions = EasyMock.createNiceMock(IOptions.class); EasyMock.expect(mockAggregator.getConfig()).andAnswer(new IAnswer<IConfig>() { @Override public IConfig answer() throws Throwable { return mockConfig; } }).anyTimes(); EasyMock.expect(mockAggregator.getOptions()).andAnswer(new IAnswer<IOptions>() { @Override public IOptions answer() throws Throwable { return mockOptions; } }).anyTimes(); EasyMock.replay(mockAggregator, mockConfig, mockOptions); Assert.assertNull(AggregatorUtil.getCacheBust(mockAggregator)); EasyMock.reset(mockConfig); EasyMock.expect(mockConfig.getCacheBust()).andReturn("abc").anyTimes(); EasyMock.replay(mockConfig); Assert.assertEquals("abc", AggregatorUtil.getCacheBust(mockAggregator)); EasyMock.reset(mockOptions); EasyMock.expect(mockOptions.getCacheBust()).andReturn("123").anyTimes(); EasyMock.replay(mockOptions); Assert.assertEquals("abc-123", AggregatorUtil.getCacheBust(mockAggregator)); EasyMock.reset(mockConfig); EasyMock.replay(mockConfig); Assert.assertEquals("123", AggregatorUtil.getCacheBust(mockAggregator)); EasyMock.reset(mockConfig); EasyMock.expect(mockConfig.getCacheBust()).andReturn("").anyTimes(); EasyMock.replay(mockConfig); Assert.assertEquals("123", AggregatorUtil.getCacheBust(mockAggregator)); EasyMock.reset(mockConfig, mockOptions); EasyMock.expect(mockConfig.getCacheBust()).andReturn("abc").anyTimes(); EasyMock.expect(mockOptions.getCacheBust()).andReturn("").anyTimes(); EasyMock.replay(mockConfig, mockOptions); Assert.assertEquals("abc", AggregatorUtil.getCacheBust(mockAggregator)); }