chore: copy kept Tastefully modules and portals into Co-Lite

Backend modules from tastefully 8bd93d15: core-libs, core-session,
api-gateway, mobile-api, services-auth, services-system,
services-counter, services-member, services-log, services-email.
solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal
from tastefully 8bd93d15. Copied as tracked files only.

Literal secrets replaced with environment placeholders:
- services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY,
  MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default)
- services-system: JUMIO_TOKEN, JUMIO_SECRET (optional)
- services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed
- core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default
  removed, ipgeolocation key read from IPGEOLOCATION_API_KEY
- services-system EkycAppConfig: commented Jumio credentials removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-11-26 15:55:45 +08:00
1 parent e396568cc3
commit 5ee51d1913
2918 files changed
+302373 -3

No files matched your search

@@ -0,0 +1,140 @@
package com.solvway.services.counter.controller;
import com.google.cloud.spring.pubsub.core.PubSubTemplate;
import com.solvway.core.utils.PubSubUtil;
import com.solvway.core.utils.ValidateUtil;
import com.solvway.services.counter.configuration.PubSubConfig;
import com.solvway.services.counter.model.CheckInBooth;
import com.solvway.services.counter.model.EventAttendance;
import com.solvway.services.counter.service.CheckInBoothService;
import com.solvway.services.counter.service.EventBoothService;
import com.solvway.services.counter.service.EventRedeemCodeService;
import com.solvway.services.counter.service.EventService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.time.LocalDate;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
/**
* One attendance per member per event per day, at any booth, whichever caller (merchant scan,
* member scan, legacy portal) asks for it: the shared counter save must not record a repeat.
*/
@ExtendWith(MockitoExtension.class)
class CheckInBoothControllerSaveTest {
private static final long EVENT = 11L;
private static final long MEMBER = 22L;
private static final long BOOTH = 33L;
private static final LocalDate DAY = LocalDate.of(2026, 11, 5);
@Mock private EventService eventService;
@Mock private CheckInBoothService checkInBoothService;
@Mock private EventBoothService eventBoothService;
@Mock private EventRedeemCodeService eventRedeemCodeService;
@Mock private ValidateUtil validateUtil;
@Mock private PubSubUtil pubSubUtil;
@Mock private PubSubConfig pubSubConfig;
@Mock private PubSubTemplate pubSubTemplate;
private CheckInBoothController controller;
@BeforeEach
void setUp() {
controller = new CheckInBoothController(eventService, checkInBoothService, eventBoothService,
eventRedeemCodeService, validateUtil, pubSubUtil, pubSubConfig, pubSubTemplate);
}
private static CheckInBooth request() {
CheckInBooth c = new CheckInBooth();
c.setEventUuid(EVENT);
c.setMemberUuid(MEMBER);
c.setStockistUuid(BOOTH);
c.setCheckInDate(DAY);
c.setCreateBy("tastefully");
c.setDoneBy("tastefully");
return c;
}
@Test
void repeatSaveSameDayReturnsExistingAndRecordsNothing() {
CheckInBooth existing = request();
existing.setId(99L);
when(checkInBoothService.findByEventUuidAndMemberUuidAndCheckInDate(
EVENT, MEMBER, DAY)).thenReturn(Optional.of(existing));
CheckInBooth result = controller.save(request());
assertThat(result).isSameAs(existing);
verify(checkInBoothService, never()).save(any());
verifyNoInteractions(eventService, eventBoothService, eventRedeemCodeService, pubSubUtil);
}
@Test
void firstSaveOfTheDayIsRecordedAndPublished() {
CheckInBooth req = request();
when(checkInBoothService.findByEventUuidAndMemberUuidAndCheckInDate(
EVENT, MEMBER, DAY)).thenReturn(Optional.empty());
when(checkInBoothService.lockDay(req)).thenReturn(true);
when(eventBoothService.findByEventUuidAndStockistUuid(EVENT, BOOTH)).thenReturn(Optional.empty());
when(checkInBoothService.save(req)).thenReturn(req);
CheckInBooth result = controller.save(req);
assertThat(result).isSameAs(req);
verify(checkInBoothService).save(req);
verify(pubSubUtil).publishMessage(any(), any(), isA(EventAttendance.class));
}
@Test
void saveAtAnotherBoothSameDayReturnsTheFirstBoothCheckIn() {
CheckInBooth boothA = request();
boothA.setStockistUuid(44L);
when(checkInBoothService.findByEventUuidAndMemberUuidAndCheckInDate(
EVENT, MEMBER, DAY)).thenReturn(Optional.of(boothA));
CheckInBooth result = controller.save(request());
assertThat(result).isSameAs(boothA);
verify(checkInBoothService, never()).save(any());
verifyNoInteractions(eventService, eventBoothService, eventRedeemCodeService, pubSubUtil);
}
@Test
void simultaneousSaveThatLosesTheLockReturnsTheWinnersCheckIn() {
CheckInBooth req = request();
CheckInBooth winner = request();
when(checkInBoothService.findByEventUuidAndMemberUuidAndCheckInDate(EVENT, MEMBER, DAY))
.thenReturn(Optional.empty(), Optional.of(winner));
when(checkInBoothService.lockDay(req)).thenReturn(false);
CheckInBooth result = controller.save(req);
assertThat(result).isSameAs(winner);
verify(checkInBoothService, never()).save(any());
verifyNoInteractions(eventService, eventBoothService, eventRedeemCodeService, pubSubUtil);
}
@Test
void simultaneousSaveThatLosesTheLockBeforeTheWinnerSavedReturnsNothing() {
CheckInBooth req = request();
when(checkInBoothService.findByEventUuidAndMemberUuidAndCheckInDate(EVENT, MEMBER, DAY))
.thenReturn(Optional.empty());
when(checkInBoothService.lockDay(req)).thenReturn(false);
assertThat(controller.save(req)).isNull();
verify(checkInBoothService, never()).save(any());
verifyNoInteractions(eventService, eventBoothService, eventRedeemCodeService, pubSubUtil);
}
}