@Before public void setUp() { logger = new ByteArrayOutputStream(); kpPairs = new ArrayList<GlobalKeepassPair>(); URL url = getClass().getResource("/TestDB.kdbx"); kpPairs.add(new GlobalKeepassPair(url.getPath(), MASTER_PASS)); vpList = new ArrayList<VarPasswordPair>(); config = EasyMock.createMockBuilder(MaskPasswordsConfig.class) .addMockedMethod("getGlobalVarPasswordPairs") .addMockedMethod("getGlobalKeepassLocations") .addMockedMethod("isMasked") .createMock(); wrapper = EasyMock.createMockBuilder(MaskPasswordsBuildWrapper.class) .addMockedMethod("getConfig") .createMock(); EasyMock.expect(config.getGlobalKeepassLocations()).andReturn(kpPairs); EasyMock.expect(config.getGlobalVarPasswordPairs()).andReturn(vpList); EasyMock.expect(config.isMasked(EasyMock.anyString())).andReturn(true).anyTimes(); EasyMock.replay(config); EasyMock.expect(wrapper.getConfig()).andReturn(config).anyTimes(); EasyMock.replay(wrapper); build = EasyMock.createMock(AbstractBuild.class); EasyMock.expect(build.getAction(ParametersAction.class)).andReturn(null); EasyMock.replay(build); }
private ImmutableZkWorker createMockWorker( int currCapacityUsed, boolean canRunTask, boolean isValidVersion) { ImmutableZkWorker worker = EasyMock.createMock(ImmutableZkWorker.class); EasyMock.expect(worker.canRunTask(EasyMock.anyObject(Task.class))) .andReturn(canRunTask) .anyTimes(); EasyMock.expect(worker.getCurrCapacityUsed()).andReturn(currCapacityUsed).anyTimes(); EasyMock.expect(worker.isValidVersion(EasyMock.anyString())) .andReturn(isValidVersion) .anyTimes(); EasyMock.replay(worker); return worker; }