Java 11 migration: patterns (t-v) (#1085)
* Moves visitor pattern to java 11 * Moves value-object pattern to java 11 * Moves unit-of-work pattern to java 11 * Moves typeobjectpattern pattern to java 11 * Moves twin pattern to java 11 * Moves trampoline pattern to java 11 * Moves tolerant-reader pattern to java 11 * Moves tls pattern to java 11 * Moves throttling pattern to java 11 * Moves thread-pool pattern to java 11 * Moves template-method pattern to java 11
This commit is contained in:
		
				
					committed by
					
						 Ilkka Seppälä
						Ilkka Seppälä
					
				
			
			
				
	
			
			
			
						parent
						
							160b737dcc
						
					
				
				
					commit
					50467c9e76
				
			| @@ -25,15 +25,12 @@ package com.iluwatar.unitofwork; | ||||
|  | ||||
| import org.junit.Test; | ||||
|  | ||||
| import java.io.IOException; | ||||
|  | ||||
| /** | ||||
|  * AppTest | ||||
|  */ | ||||
| public class AppTest { | ||||
|   @Test | ||||
|   public void test() { | ||||
|     String[] args = {}; | ||||
|     App.main(args); | ||||
|     App.main(new String[]{}); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -23,20 +23,22 @@ | ||||
|  | ||||
| package com.iluwatar.unitofwork; | ||||
|  | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.mockito.Mockito.never; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.verifyNoMoreInteractions; | ||||
| import static org.mockito.Mockito.verifyZeroInteractions; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.mockito.Mock; | ||||
| import org.mockito.runners.MockitoJUnitRunner; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.mockito.Mockito.*; | ||||
|  | ||||
| /** | ||||
|  * tests {@link StudentRepository} | ||||
|  */ | ||||
| @@ -51,7 +53,7 @@ public class StudentRepositoryTest { | ||||
|   private StudentRepository studentRepository; | ||||
|  | ||||
|   @Before | ||||
|   public void setUp() throws Exception { | ||||
|   public void setUp() { | ||||
|     context = new HashMap<>(); | ||||
|     studentRepository = new StudentRepository(context, studentDatabase); | ||||
|   } | ||||
| @@ -85,9 +87,9 @@ public class StudentRepositoryTest { | ||||
|  | ||||
|   @Test | ||||
|   public void shouldSaveAllLocalChangesToDb() { | ||||
|     context.put(IUnitOfWork.INSERT, Collections.singletonList(student1)); | ||||
|     context.put(IUnitOfWork.MODIFY, Collections.singletonList(student1)); | ||||
|     context.put(IUnitOfWork.DELETE, Collections.singletonList(student1)); | ||||
|     context.put(IUnitOfWork.INSERT, List.of(student1)); | ||||
|     context.put(IUnitOfWork.MODIFY, List.of(student1)); | ||||
|     context.put(IUnitOfWork.DELETE, List.of(student1)); | ||||
|  | ||||
|     studentRepository.commit(); | ||||
|  | ||||
| @@ -116,8 +118,8 @@ public class StudentRepositoryTest { | ||||
|  | ||||
|   @Test | ||||
|   public void shouldNotInsertToDbIfNoRegisteredStudentsToBeCommitted() { | ||||
|     context.put(IUnitOfWork.MODIFY, Collections.singletonList(student1)); | ||||
|     context.put(IUnitOfWork.DELETE, Collections.singletonList(student1)); | ||||
|     context.put(IUnitOfWork.MODIFY, List.of(student1)); | ||||
|     context.put(IUnitOfWork.DELETE, List.of(student1)); | ||||
|  | ||||
|     studentRepository.commit(); | ||||
|  | ||||
| @@ -126,8 +128,8 @@ public class StudentRepositoryTest { | ||||
|  | ||||
|   @Test | ||||
|   public void shouldNotModifyToDbIfNotRegisteredStudentsToBeCommitted() { | ||||
|     context.put(IUnitOfWork.INSERT, Collections.singletonList(student1)); | ||||
|     context.put(IUnitOfWork.DELETE, Collections.singletonList(student1)); | ||||
|     context.put(IUnitOfWork.INSERT, List.of(student1)); | ||||
|     context.put(IUnitOfWork.DELETE, List.of(student1)); | ||||
|  | ||||
|     studentRepository.commit(); | ||||
|  | ||||
| @@ -136,8 +138,8 @@ public class StudentRepositoryTest { | ||||
|  | ||||
|   @Test | ||||
|   public void shouldNotDeleteFromDbIfNotRegisteredStudentsToBeCommitted() { | ||||
|     context.put(IUnitOfWork.INSERT, Collections.singletonList(student1)); | ||||
|     context.put(IUnitOfWork.MODIFY, Collections.singletonList(student1)); | ||||
|     context.put(IUnitOfWork.INSERT, List.of(student1)); | ||||
|     context.put(IUnitOfWork.MODIFY, List.of(student1)); | ||||
|  | ||||
|     studentRepository.commit(); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user