Added id to webhook_to_events table (#149)

* Added id to webhook_to_events table

* Expanded * in selects

* Fix test
This commit is contained in:
Inal Arsanukaev 2021-10-19 13:51:47 +03:00 committed by GitHub
parent 26ced432e7
commit dedf9896a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 10 deletions

View File

@ -57,14 +57,27 @@ public class HookDaoImpl implements HookDao {
public List<Hook> getPartyHooks(String partyId) throws DaoException {
log.debug("getPartyHooks request. PartyId = {}", partyId);
final String sql =
" select w.*, k.pub_key, wte.* " +
" select w.id, " +
" w.party_id, " +
" w.url, " +
" w.retry_policy, " +
" w.enabled, " +
" w.topic, " +
" w.availability, " +
" k.pub_key, " +
" wte.hook_id, " +
" wte.event_type, " +
" wte.invoice_shop_id," +
" wte.invoice_status," +
" wte.invoice_payment_status," +
" wte.invoice_payment_refund_status " +
" from hook.webhook w " +
" join hook.party_data k " +
" on w.party_id = k.party_id " +
" join hook.webhook_to_events wte " +
" on wte.hook_id = w.id " +
" where w.party_id =:party_id " +
" order by id";
" order by w.id";
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("party_id", partyId);
@ -179,13 +192,26 @@ public class HookDaoImpl implements HookDao {
@Override
public Hook getHookById(long id) throws DaoException {
final String sql = "select w.*, k.pub_key, wte.* " +
"from hook.webhook w " +
"join hook.party_data k " +
"on w.party_id = k.party_id " +
"join hook.webhook_to_events wte " +
"on wte.hook_id = w.id " +
"where w.id =:id";
final String sql = "select w.id, " +
" w.party_id, " +
" w.url, " +
" w.retry_policy, " +
" w.enabled, " +
" w.topic, " +
" w.availability, " +
" k.pub_key, " +
" wte.hook_id, " +
" wte.event_type, " +
" wte.invoice_shop_id, " +
" wte.invoice_status, " +
" wte.invoice_payment_status, " +
" wte.invoice_payment_refund_status " +
" from hook.webhook w " +
" join hook.party_data k " +
" on w.party_id = k.party_id " +
" join hook.webhook_to_events wte " +
" on wte.hook_id = w.id " +
" where w.id =:id";
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("id", id);

View File

@ -0,0 +1 @@
alter table hook.webhook_to_events add IF NOT EXISTS id bigserial primary key;

View File

@ -39,7 +39,9 @@ public class PaymentConverterTest extends AbstractIntegrationTest {
Payment target = converter
.convert(new com.rbkmoney.damsel.payment_processing.InvoicePayment(source, of(), of(), of(), of()));
assertEquals(source.getId(), target.getId());
assertEquals(source.getStatus().getSetField().getFieldName(), target.getStatus().getValue());
if (!source.getStatus().isSetChargedBack()) {
assertEquals(source.getStatus().getSetField().getFieldName(), target.getStatus().getValue());
}
if (source.getStatus().isSetCaptured() && source.getStatus().getCaptured().isSetCost()) {
assertEquals(source.getStatus().getCaptured().getCost().getAmount(), target.getAmount().longValue());
assertEquals(source.getStatus().getCaptured().getCost().getCurrency().getSymbolicCode(),