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