parent
a8b29ac936
commit
8a8ed24cfa
@ -0,0 +1,33 @@ |
|||||||
|
package me.bearns.fias.helper; |
||||||
|
|
||||||
|
import me.bearns.fias.domain.FiasVersion; |
||||||
|
import me.bearns.fias.exceptions.CommonException; |
||||||
|
import me.bearns.fias.exceptions.UnmarshallingException; |
||||||
|
import me.bearns.fias.repository.FiasVersionRepository; |
||||||
|
import org.springframework.boot.test.context.TestComponent; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
@TestComponent |
||||||
|
public class TransactionalSaveHelper { |
||||||
|
|
||||||
|
private FiasVersionRepository repository; |
||||||
|
|
||||||
|
public static final long FIRST = 1L; |
||||||
|
public static final long NEXT = 2L; |
||||||
|
|
||||||
|
public void setRepository(FiasVersionRepository repository) { |
||||||
|
this.repository = repository; |
||||||
|
} |
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class) |
||||||
|
public void addNext() throws CommonException { |
||||||
|
final FiasVersion nextVersion = new FiasVersion(NEXT, null, null, null); |
||||||
|
repository.save(nextVersion); |
||||||
|
throw new UnmarshallingException("test"); |
||||||
|
} |
||||||
|
|
||||||
|
public void addFirst() { |
||||||
|
final FiasVersion version = new FiasVersion(FIRST, null, null, null); |
||||||
|
repository.save(version); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue