Java 11 migration: ambassador async-method-invocation balking bridge builder (#1076)
* Moves ambassador pattern to java 11 * Moves async-method-invocation pattern to java 11 * Moves balking pattern to java 11 * Moves bridge pattern to java 11 * Moves builder pattern to java 11
This commit is contained in:
		
				
					committed by
					
						 Ilkka Seppälä
						Ilkka Seppälä
					
				
			
			
				
	
			
			
			
						parent
						
							f0f0143d48
						
					
				
				
					commit
					c4418311c6
				
			| @@ -51,8 +51,8 @@ public class App { | ||||
|    * @param args the command line arguments - not used | ||||
|    */ | ||||
|   public static void main(String... args) { | ||||
|     final WashingMachine washingMachine = new WashingMachine(); | ||||
|     ExecutorService executorService = Executors.newFixedThreadPool(3); | ||||
|     final var washingMachine = new WashingMachine(); | ||||
|     var executorService = Executors.newFixedThreadPool(3); | ||||
|     for (int i = 0; i < 3; i++) { | ||||
|       executorService.execute(washingMachine::wash); | ||||
|     } | ||||
|   | ||||
| @@ -68,7 +68,7 @@ public class WashingMachine { | ||||
|    */ | ||||
|   public void wash() { | ||||
|     synchronized (this) { | ||||
|       WashingMachineState machineState = getWashingMachineState(); | ||||
|       var machineState = getWashingMachineState(); | ||||
|       LOGGER.info("{}: Actual machine state: {}", Thread.currentThread().getName(), machineState); | ||||
|       if (this.washingMachineState == WashingMachineState.WASHING) { | ||||
|         LOGGER.error("ERROR: Cannot wash if the machine has been already washing!"); | ||||
|   | ||||
| @@ -28,12 +28,11 @@ import org.junit.jupiter.api.Test; | ||||
| /** | ||||
|  * Application test | ||||
|  */ | ||||
| public class AppTest { | ||||
| class AppTest { | ||||
|  | ||||
|   @Test | ||||
|   public void main() throws Exception { | ||||
|     String[] args = {}; | ||||
|     App.main(args); | ||||
|   void main() { | ||||
|     App.main(); | ||||
|   } | ||||
|  | ||||
| } | ||||
| @@ -31,18 +31,18 @@ import org.junit.jupiter.api.Test; | ||||
| /** | ||||
|  * Tests for {@link WashingMachine} | ||||
|  */ | ||||
| public class WashingMachineTest { | ||||
| class WashingMachineTest { | ||||
|  | ||||
|   private FakeDelayProvider fakeDelayProvider = new FakeDelayProvider(); | ||||
|   private final FakeDelayProvider fakeDelayProvider = new FakeDelayProvider(); | ||||
|  | ||||
|   @Test | ||||
|   public void wash() { | ||||
|     WashingMachine washingMachine = new WashingMachine(fakeDelayProvider); | ||||
|   void wash() { | ||||
|     var washingMachine = new WashingMachine(fakeDelayProvider); | ||||
|  | ||||
|     washingMachine.wash(); | ||||
|     washingMachine.wash(); | ||||
|  | ||||
|     WashingMachineState machineStateGlobal = washingMachine.getWashingMachineState(); | ||||
|     var machineStateGlobal = washingMachine.getWashingMachineState(); | ||||
|  | ||||
|     fakeDelayProvider.task.run(); | ||||
|  | ||||
| @@ -54,13 +54,13 @@ public class WashingMachineTest { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void endOfWashing() { | ||||
|     WashingMachine washingMachine = new WashingMachine(); | ||||
|   void endOfWashing() { | ||||
|     var washingMachine = new WashingMachine(); | ||||
|     washingMachine.wash(); | ||||
|     assertEquals(WashingMachineState.ENABLED, washingMachine.getWashingMachineState()); | ||||
|   } | ||||
|  | ||||
|   private class FakeDelayProvider implements DelayProvider { | ||||
|   private static class FakeDelayProvider implements DelayProvider { | ||||
|     private Runnable task; | ||||
|  | ||||
|     @Override | ||||
|   | ||||
		Reference in New Issue
	
	Block a user