mirror of
https://github.com/valitydev/shumpune.git
synced 2024-11-06 02:25:22 +00:00
Add test for bug
This commit is contained in:
parent
15b6faecc8
commit
f74a1b4282
@ -5,6 +5,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@ -17,6 +19,7 @@ import org.testcontainers.containers.PostgreSQLContainer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@EnableConfigurationProperties({DataSourceProperties.class})
|
||||
@ContextConfiguration(initializers = DaoTestBase.Initializer.class)
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||
@Slf4j
|
||||
@ -52,6 +55,7 @@ public abstract class DaoTestBase extends AbstractTestUtils {
|
||||
TestPropertyValues
|
||||
.of(testContainers.getEnvironmentProperties(getEnvironmentPropertiesConsumer()))
|
||||
.applyTo(configurableApplicationContext);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,9 @@ import com.rbkmoney.shumpune.constant.PostingOperation;
|
||||
import com.rbkmoney.shumpune.dao.AccountDao;
|
||||
import com.rbkmoney.shumpune.dao.PlanDao;
|
||||
import com.rbkmoney.shumpune.domain.BalanceModel;
|
||||
import com.rbkmoney.shumpune.domain.PostingModel;
|
||||
import com.rbkmoney.shumpune.domain.PostingPlanInfo;
|
||||
import com.rbkmoney.shumpune.domain.PostingPlanModel;
|
||||
import com.rbkmoney.shumpune.utils.AccountGenerator;
|
||||
import com.rbkmoney.shumpune.utils.PostingGenerator;
|
||||
import com.rbkmoney.shumpune.utils.VectorClockSerializer;
|
||||
@ -28,6 +31,8 @@ import java.util.List;
|
||||
@SpringBootTest(classes = ShumpuneApplication.class)
|
||||
public class ShumpuneServiceHandlerTest extends DaoTestBase {
|
||||
|
||||
public static final String ID = "16J1L7A6Swq.1";
|
||||
|
||||
@Autowired
|
||||
JdbcTemplate jdbcTemplate;
|
||||
|
||||
@ -304,4 +309,57 @@ public class ShumpuneServiceHandlerTest extends DaoTestBase {
|
||||
Assert.assertEquals(accountPrototype.getDescription(), account.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addOrUpdatePlanLog() {
|
||||
PostingPlanModel planLog = new PostingPlanModel();
|
||||
PostingPlanInfo postingPlanInfo = new PostingPlanInfo();
|
||||
postingPlanInfo.setClock(0L);
|
||||
postingPlanInfo.setPostingOperation(PostingOperation.HOLD);
|
||||
postingPlanInfo.setBatchId(1L);
|
||||
postingPlanInfo.setId(ID);
|
||||
planLog.setPostingPlanInfo(postingPlanInfo);
|
||||
ArrayList<PostingModel> postingModels = new ArrayList<>();
|
||||
PostingModel postingModel = new PostingModel();
|
||||
postingModel.setAccountFromId(13L);
|
||||
postingModel.setAccountToId(1L);
|
||||
postingModel.setAmount(4500L);
|
||||
postingModel.setCurrencySymbCode("RUB");
|
||||
postingModels.add(postingModel);
|
||||
|
||||
postingModel = new PostingModel();
|
||||
postingModel.setAccountFromId(4L);
|
||||
postingModel.setAccountToId(13L);
|
||||
postingModel.setAmount(10000L);
|
||||
postingModel.setCurrencySymbCode("RUB");
|
||||
postingModels.add(postingModel);
|
||||
|
||||
postingModel = new PostingModel();
|
||||
postingModel.setAccountFromId(1L);
|
||||
postingModel.setAccountToId(4L);
|
||||
postingModel.setAmount(1500L);
|
||||
postingModel.setCurrencySymbCode("RUB");
|
||||
postingModels.add(postingModel);
|
||||
|
||||
planLog.setPostingModels(postingModels);
|
||||
PostingPlanModel postingPlanModel = planDao.addOrUpdatePlanLog(planLog);
|
||||
|
||||
Assert.assertEquals(ID, postingPlanModel.getPostingPlanInfo().getId());
|
||||
|
||||
planLog.getPostingPlanInfo().setBatchId(2L);
|
||||
postingPlanModel = planDao.addOrUpdatePlanLog(planLog);
|
||||
|
||||
Assert.assertEquals(ID, postingPlanModel.getPostingPlanInfo().getId());
|
||||
|
||||
planLog.getPostingPlanInfo().setPostingOperation(PostingOperation.COMMIT);
|
||||
PostingPlanInfo postingPlanModelInfo = planDao.updatePlanLog(planLog.getPostingPlanInfo());
|
||||
|
||||
Assert.assertEquals(ID, postingPlanModelInfo.getId());
|
||||
Assert.assertEquals(PostingOperation.COMMIT, postingPlanModelInfo.getPostingOperation());
|
||||
|
||||
planLog.getPostingPlanInfo().setPostingOperation(PostingOperation.HOLD);
|
||||
postingPlanModel = planDao.addOrUpdatePlanLog(planLog);
|
||||
Assert.assertEquals(PostingOperation.COMMIT, postingPlanModel.getPostingPlanInfo().getPostingOperation());
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user