In this post under Hibernate, I will explain how to create a unidirectional one to many association between objects using a mapping file with an example. For our example, we will create the below two tables. Data Definition Language CREATE TABLE `series1` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(50) NOT NULL, `description` VARCHAR(100) NOT…… Continue reading Unidirectional One to Many association mapping (without annotations)
Month: April 2019
Stubbing consecutive method calls
In this post under mockito, I will explain how to stub consecutive method calls with example. Consecutive method calls meaning sometimes we call same method multiple times. In that case we have to stub the method to return values consecutively. Below is the complete code for your reference Test Class 1 package package7; 2 3…… Continue reading Stubbing consecutive method calls
Stubbing a default interface method
In this post under Mockito, I will explain how to change a default interface method implementation for testing purposes with an example. For testing purposes I have created an interface as shown below Interface1 package package6; public interface Interface1 { public default int method1(int value) { return value * 2; } } The test case…… Continue reading Stubbing a default interface method
Mocking an interface
In this post under Mockito, I will show how to create a mock of an interface with an example Below is the complete example where I create a mock of java.util.List interface and call its method. Test Class 1 package package3; 2 3 import static org.junit.Assert.assertEquals; 4 import static org.mockito.Mockito.when; 5 6 import java.util.List; 7…… Continue reading Mocking an interface
SuffixRecordSeparatorPolicy example
In this post under Spring Batch, I will explain the purpose and how to use SuffixRecordSeparatorPolicy class with an example. SuffixRecordSeparatorPolicy class is a concrete implementation of org.springframework.batch.item.file.separator.RecordSeparatorPolicy interface. In one of my previous post I have explained the purpose of RecordSeparatorPolicy and how to use it. For recap, RecordSeparatorPolicy interface is used to tell…… Continue reading SuffixRecordSeparatorPolicy example