fix: resolve compilation errors, mock signatures, and missing DTO constructors
This commit is contained in:
parent
abeb99ed61
commit
9781efeb6c
@ -1,8 +1,12 @@
|
||||
package com.walkguide.dto.response;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AiConfigResponse {
|
||||
private Long id;
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
package com.walkguide.dto.response;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class DashboardResponse {
|
||||
// Info user yang dipair
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package com.walkguide.dto.response;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GeofenceResponse {
|
||||
private Long id;
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package com.walkguide.dto.response;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class HardwareShortcutResponse {
|
||||
private Long id;
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
package com.walkguide.dto.response;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class LocationResponse {
|
||||
private Long id;
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
package com.walkguide.dto.response;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class NotificationResponse {
|
||||
private Long id;
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
package com.walkguide.dto.response;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class ObstacleLogResponse {
|
||||
private Long id;
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package com.walkguide.dto.response;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class UserSettingsResponse {
|
||||
private Long id;
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package com.walkguide.dto.response;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class VoiceCommandResponse {
|
||||
private Long id;
|
||||
|
||||
@ -10,4 +10,5 @@ public interface GuardianNotificationRepository extends JpaRepository<GuardianNo
|
||||
Page<GuardianNotification> findByUserIdOrderByCreatedAtDesc(Long userId, Pageable pageable);
|
||||
long countByUserIdAndIsReadFalse(Long userId);
|
||||
List<GuardianNotification> findByUserIdAndIsReadFalseOrderByCreatedAtAsc(Long userId);
|
||||
java.util.Optional<GuardianNotification> findByIdAndUserId(Long id, Long userId);
|
||||
}
|
||||
|
||||
@ -6,5 +6,6 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface HardwareShortcutRepository extends JpaRepository<HardwareShortcut, Long> {
|
||||
List<HardwareShortcut> findByUserId(Long userId);
|
||||
boolean existsByUserId(Long userId);
|
||||
void deleteByUserId(Long userId);
|
||||
}
|
||||
|
||||
@ -9,5 +9,6 @@ import java.util.Optional;
|
||||
public interface VoiceCommandConfigRepository extends JpaRepository<VoiceCommandConfig, Long> {
|
||||
List<VoiceCommandConfig> findByUserId(Long userId);
|
||||
Optional<VoiceCommandConfig> findByUserIdAndCommandKey(Long userId, VoiceCommandKey commandKey);
|
||||
boolean existsByUserId(Long userId);
|
||||
void deleteByUserId(Long userId);
|
||||
}
|
||||
|
||||
@ -90,6 +90,16 @@ public class NotificationService {
|
||||
notifRepository.saveAll(unread);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void markAsRead(Long userId, Long notifId) {
|
||||
GuardianNotification notif = notifRepository.findByIdAndUserId(notifId, userId)
|
||||
.orElseThrow(() -> new com.walkguide.exception.ResourceNotFoundException(
|
||||
"Notifikasi tidak ditemukan"));
|
||||
notif.setIsRead(true);
|
||||
notif.setReadAt(LocalDateTime.now());
|
||||
notifRepository.save(notif);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void markOneRead(Long notifId) {
|
||||
notifRepository.findById(notifId).ifPresent(n -> {
|
||||
|
||||
@ -84,8 +84,7 @@ class CallControllerTest {
|
||||
AgoraTokenResponse tokenResp = AgoraTokenResponse.builder()
|
||||
.token("agora-rtc-token-xyz")
|
||||
.channelName("call_1_2_1234567890")
|
||||
.callerUid(1001)
|
||||
.receiverUid(1002)
|
||||
.uid(1001)
|
||||
.build();
|
||||
|
||||
when(agoraTokenService.generateToken(1L, 2L)).thenReturn(tokenResp);
|
||||
|
||||
@ -213,8 +213,8 @@ class UserControllerTest {
|
||||
sh.when(SecurityHelper::getCurrentUserId).thenReturn(1L);
|
||||
|
||||
LocationUpdateRequest req = new LocationUpdateRequest();
|
||||
req.setLatitude(-7.2575);
|
||||
req.setLongitude(112.7521);
|
||||
req.setLat(-7.2575);
|
||||
req.setLng(112.7521);
|
||||
|
||||
LocationResponse resp = new LocationResponse();
|
||||
when(locationService.updateLocation(eq(1L), any())).thenReturn(resp);
|
||||
|
||||
@ -87,7 +87,7 @@ class GuardianDashboardServiceTest {
|
||||
when(activityLogService.getLogs(eq(5L), any(PageRequest.class)))
|
||||
.thenReturn(new PageImpl<>(List.of()));
|
||||
when(sosEventRepository.findByUserIdOrderByCreatedAtDesc(eq(5L), any(PageRequest.class)))
|
||||
.thenReturn(List.of());
|
||||
.thenReturn(new PageImpl<>(List.of()));
|
||||
when(notifRepository.countByUserIdAndIsReadFalse(5L)).thenReturn(0L);
|
||||
|
||||
DashboardResponse result = guardianDashboardService.getDashboard(10L);
|
||||
@ -114,7 +114,7 @@ class GuardianDashboardServiceTest {
|
||||
when(activityLogService.getLogs(eq(5L), any(PageRequest.class)))
|
||||
.thenReturn(new PageImpl<>(List.of()));
|
||||
when(sosEventRepository.findByUserIdOrderByCreatedAtDesc(eq(5L), any(PageRequest.class)))
|
||||
.thenReturn(List.of(triggered, acknowledged, resolved));
|
||||
.thenReturn(new PageImpl<>(List.of(triggered, acknowledged, resolved)));
|
||||
when(notifRepository.countByUserIdAndIsReadFalse(5L)).thenReturn(0L);
|
||||
|
||||
DashboardResponse result = guardianDashboardService.getDashboard(10L);
|
||||
@ -132,7 +132,7 @@ class GuardianDashboardServiceTest {
|
||||
when(activityLogService.getLogs(eq(5L), any(PageRequest.class)))
|
||||
.thenReturn(new PageImpl<>(List.of()));
|
||||
when(sosEventRepository.findByUserIdOrderByCreatedAtDesc(eq(5L), any(PageRequest.class)))
|
||||
.thenReturn(List.of());
|
||||
.thenReturn(new PageImpl<>(List.of()));
|
||||
when(notifRepository.countByUserIdAndIsReadFalse(5L)).thenReturn(7L);
|
||||
|
||||
DashboardResponse result = guardianDashboardService.getDashboard(10L);
|
||||
@ -152,7 +152,7 @@ class GuardianDashboardServiceTest {
|
||||
when(activityLogService.getLogs(eq(5L), eq(PageRequest.of(0, 5))))
|
||||
.thenReturn(new PageImpl<>(List.of(log1, log2)));
|
||||
when(sosEventRepository.findByUserIdOrderByCreatedAtDesc(eq(5L), any(PageRequest.class)))
|
||||
.thenReturn(List.of());
|
||||
.thenReturn(new PageImpl<>(List.of()));
|
||||
when(notifRepository.countByUserIdAndIsReadFalse(5L)).thenReturn(0L);
|
||||
|
||||
DashboardResponse result = guardianDashboardService.getDashboard(10L);
|
||||
@ -174,7 +174,7 @@ class GuardianDashboardServiceTest {
|
||||
when(activityLogService.getLogs(eq(5L), any(PageRequest.class)))
|
||||
.thenReturn(new PageImpl<>(List.of()));
|
||||
when(sosEventRepository.findByUserIdOrderByCreatedAtDesc(eq(5L), any(PageRequest.class)))
|
||||
.thenReturn(List.of(ack, res));
|
||||
.thenReturn(new PageImpl<>(List.of(ack, res)));
|
||||
when(notifRepository.countByUserIdAndIsReadFalse(5L)).thenReturn(0L);
|
||||
|
||||
DashboardResponse result = guardianDashboardService.getDashboard(10L);
|
||||
|
||||
@ -140,7 +140,7 @@ class NotificationServiceTest {
|
||||
|
||||
notificationService.markAsRead(2L, 100L);
|
||||
|
||||
assertThat(notif.isRead()).isTrue();
|
||||
assertThat(notif.getIsRead()).isTrue();
|
||||
verify(notifRepository).save(notif);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user