Lombok
Helps reduce boilerplate code (getters, setters, constructors, etc): lombok doc
@Data: combination of the following annotations@Getter: generates getter methods for all fields@Setter: generates setter methods for all non-final fields@ToString: generates a toString() method with the following default: the class name followed by parentheses containing fields separated by commas, e.g. MyClass(foo=123, bar=234).@EqualsAndHashCode: generates equals(Object other) and hashCode() methods; uses all non-static and non-transient fields (private/public Type name)@RequiredArgsConstructor: generates a constructor with required arguments for fields that arefinalor have@NonNull@NoArgsConstructor: generates a no-argument constructor@AllArgsConstructor: generates a constructor with all fields as parameters
View Templates Libraries
- Thymeleaf
- FreeMarker
- Groovy templates
- JavaServer Pages (JSP)
- Mustache
Testing
JUnit : popular unit testing framework
@Test: identifies a method as a test method@BeforeEach: Executed before each test. Used to prepare the test environment(e.g. read input data, initialize the class)@AfterEach: Executed after each test. Used to cleanup test environment@BeforeAll: Executed once, before the start of all tests. Methods marked with this annotation need to be defined as static to work with JUnit@AfterAll: Executed once, after all tests have been finished. Methods need to be static to work with JUnit@@Test(expected = Exception.class): Fails if the method does not throw the named exception@Test(timeout = 10): Fails if the method takes longer than 100 miliseconds
JUnit Built-In Assertion Methods
assertEquals(expected, actual)assertNotEquals(unexpected, actual)assertTrue(condition)assertFalse(condition)assertNull(object)assertNotNull(object)assertSame(expected, actual)assertNotSame(unexpected, actual)assertArrayEquals(expected, actual)assertIterableEquals(expected, actual)assertThrows(Exception.class, () -> code)assertDoesNotThrow(() -> code)
Spring Boot Annotations :
@RunWith(SpringRunner.class)Run test with Spring Context@SpringBootTestSearch for Spring Boot Application for configuration@TestConfigurationSpecify a Spring configuration for your test@MockBeanInjects Mockito Mock@SpyBeanInjects Mockito Spy@JsonTestCreates a Jackson or Gson object mapper@@DataJpaTestUsed to test data layer with embedded database