Java tutorial
package ch.wscr.management; import ch.wscr.management.db.model.Member; import ch.wscr.management.db.repository.MemberRepository; import ch.wscr.management.util.Country; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import java.sql.Date; import java.util.Calendar; import java.util.GregorianCalendar; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = WscrManagementApplication.class) @WebAppConfiguration @TestPropertySource(locations = "classpath:application.properties") public class WscrManagementApplicationTests { @Autowired MemberRepository memberRepository; @Test public void contextLoads() { } @Test public void storeMemberTest() { Member memberToSave = new Member(); memberToSave.setFirstName("Marco"); memberToSave.setLastName("Nitschke"); memberToSave.setBirthDate(new Date(new GregorianCalendar(1977, Calendar.JANUARY, 20).getTimeInMillis())); memberToSave.setAdrStreet("Rilkeweg 9"); memberToSave.setAdrPostalCode("70771"); memberToSave.setAdrCity("Echterdingen"); memberToSave.setDriverLicense(true); memberToSave.setAdrCountry(Country.DE); Member memberSaved = memberRepository.save(memberToSave); assertThat(memberSaved.getMemberId(), is(1)); } }