@Test(timeOut = 5000) public void testRequestServerWorldFile() throws Exception { WorldClient worldClient = Mockito.mock(WorldClient.class); WorldClientMessageFactory messageFactory = Mockito.mock(WorldClientMessageFactory.class); File worldFile = Mockito.mock(File.class); Message message = Mockito.mock(Message.class); MessageIO messageIO = Mockito.mock(MessageIO.class); Mockito.when(worldClient.getMessageFactory()).thenReturn(messageFactory); Mockito.when(message.getArgument("fileBytes")).thenReturn("abc123".getBytes()); Mockito.when(messageFactory.generateWorldChecksumRequest()).thenReturn(message); Mockito.when(worldClient.getMessageIO()).thenReturn(messageIO); ServerWorldFileTracker serverWorldFileTracker = new ServerWorldFileTracker(worldClient, worldFile); Mockito.when(worldClient.getServerWorldFileTracker()).thenReturn(serverWorldFileTracker); serverWorldFileTracker.setWaitingForFile(true); serverWorldFileTracker.requestServerWorldFile(); Assert.assertTrue(serverWorldFileTracker.isWaitingForFile()); ExecutableWorldFileResponse exec = new ExecutableWorldFileResponse(worldClient, message); exec.runImmediate(); Assert.assertFalse(serverWorldFileTracker.isWaitingForFile()); Assert.assertEquals(serverWorldFileTracker.getBytes(), "abc123".getBytes()); }
public void requestServerWorldFile() { if (needsWorldFile()) { this.worldClient.getMessageIO().queueOutgoingMessage(this.worldClient.getMessageFactory() .generateWorldFileRequest()); } else { setWaitingForFile(false); } }
ServerWorldFileTracker { public void requestServerWorldFile() { if (needsWorldFile()) { this.worldClient.getMessageIO().queueOutgoingMessage(this.worldClient.getMessageFactory() .generateWorldFileRequest()); } else { setWaitingForFile(false); } } }
ServerWorldFileTracker { public void requestServerWorldFile() { if (needsWorldFile()) { this.worldClient.getMessageIO().queueOutgoingMessage(this.worldClient.getMessageFactory() .generateWorldFileRequest()); } else { setWaitingForFile(false); } } ServerWorldFileTracker(WorldClient worldClient, File worldFile); }
ServerWorldFileTracker { public void requestServerWorldFile() { if (needsWorldFile()) { this.worldClient.getMessageIO().queueOutgoingMessage(this.worldClient.getMessageFactory() .generateWorldFileRequest()); } else { setWaitingForFile(false); } } ServerWorldFileTracker(WorldClient worldClient, File worldFile); void requestServerWorldFileChecksum(); void requestServerWorldFile(); void writeReceivedWorldToFile(); byte[] getChecksum(); void setChecksum(byte[] checksum); byte[] getBytes(); void setBytes(byte[] bytes); boolean isWaitingForChecksum(); void setWaitingForChecksum(boolean bool); boolean isWaitingForFile(); void setWaitingForFile(boolean waiting); void waitForWorldFile(); void waitForWorldFileChecksum(); }
ServerWorldFileTracker { public void requestServerWorldFile() { if (needsWorldFile()) { this.worldClient.getMessageIO().queueOutgoingMessage(this.worldClient.getMessageFactory() .generateWorldFileRequest()); } else { setWaitingForFile(false); } } ServerWorldFileTracker(WorldClient worldClient, File worldFile); void requestServerWorldFileChecksum(); void requestServerWorldFile(); void writeReceivedWorldToFile(); byte[] getChecksum(); void setChecksum(byte[] checksum); byte[] getBytes(); void setBytes(byte[] bytes); boolean isWaitingForChecksum(); void setWaitingForChecksum(boolean bool); boolean isWaitingForFile(); void setWaitingForFile(boolean waiting); void waitForWorldFile(); void waitForWorldFileChecksum();  }