TransactionsTest (failed)
This commit is contained in:
@@ -10,6 +10,7 @@ import me.bearns.fias.util.RegionFilter;
|
||||
import me.bearns.fias.util.UnmarshallerParameters;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@@ -84,6 +85,7 @@ public class FiasUpdater implements Updater {
|
||||
}
|
||||
|
||||
//transaction from here
|
||||
@Transactional
|
||||
private void processUpdates(List<FiasVersion> updates, boolean reloadFlag) throws CommonException {
|
||||
|
||||
if(reloadFlag) {
|
||||
|
||||
@@ -14,7 +14,7 @@ databaseChangeLog:
|
||||
nullable: false
|
||||
- column:
|
||||
name: aoguid
|
||||
type: uuod
|
||||
type: uuid
|
||||
- column:
|
||||
name: parentguid
|
||||
type: uuid
|
||||
|
||||
@@ -14,10 +14,10 @@ databaseChangeLog:
|
||||
nullable: false
|
||||
- column:
|
||||
name: aoguid
|
||||
type: uuod
|
||||
type: uuid
|
||||
- column:
|
||||
name: houseguid
|
||||
type: uuod
|
||||
type: uuid
|
||||
- column:
|
||||
name: buildnum
|
||||
type: varchar(255)
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
databaseChangeLog:
|
||||
- include:
|
||||
- file: "000_initial_schema.yaml"
|
||||
- file: "001_AddrObj.yaml"
|
||||
- file: "002_House.yaml"
|
||||
- relativeToChangelogFile: "true"
|
||||
- relativeToChangelogFile: "true"
|
||||
- include:
|
||||
- file: "001_AddrObj.yaml"
|
||||
- relativeToChangelogFile: "true"
|
||||
- include:
|
||||
- file: "002_House.yaml"
|
||||
- relativeToChangelogFile: "true"
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package me.bearns.fias;
|
||||
|
||||
import me.bearns.fias.domain.FiasVersion;
|
||||
import me.bearns.fias.repository.FiasVersionRepository;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.transaction.annotation.Isolation.READ_COMMITTED;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class TransactionsTest {
|
||||
|
||||
private static final long FIRST = 1L;
|
||||
private static final long NEXT = 2L;
|
||||
|
||||
@Autowired
|
||||
private FiasVersionRepository repository;
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
final FiasVersion version = new FiasVersion(FIRST, null, null, null);
|
||||
repository.save(version);
|
||||
|
||||
try {
|
||||
addNext();
|
||||
} catch (Exception e) {
|
||||
//just as planed
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionTest(){
|
||||
|
||||
final List<FiasVersion> versions = repository.findAll();
|
||||
|
||||
versions.stream().map(FiasVersion::getVersionId).forEach(System.out::println);
|
||||
|
||||
assert versions.stream().mapToLong(FiasVersion::getVersionId).anyMatch(v -> FIRST == v);
|
||||
|
||||
assert versions.stream().mapToLong(FiasVersion::getVersionId).noneMatch(v -> NEXT == v);
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addNext() throws Exception {
|
||||
final FiasVersion nextVersion = new FiasVersion(NEXT, null, null, null);
|
||||
repository.save(nextVersion);
|
||||
throw new Exception("test");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user