Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import java.time.LocalDateTime;
import java.util.List;

public record MemberFindResponse(List<MemberFindElement> devices) {
public record MemberFindResponse(String email, List<MemberFindElement> devices) {

public static MemberFindResponse from(final MemberFindOutput output) {
final List<MemberFindElement> memberFindElements = output.elements().stream()
.map(outputElement -> new MemberFindElement(outputElement.email().getValue(),
.map(outputElement -> new MemberFindElement(outputElement.identifier().getValue(),
outputElement.createdAt()))
.toList();
return new MemberFindResponse(memberFindElements);
return new MemberFindResponse(output.email().getValue(), memberFindElements);
}

private record MemberFindElement(String email, LocalDateTime createdAt) {
private record MemberFindElement(String identifier, LocalDateTime createdAt) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public MemberFindOutput findAllMemberDevices(final MemberFindInput input) {
checkActiveDevice(input.deviceIdentifier());

final List<Device> devices = deviceRepository.findAllByMemberEmail(input.email());
return MemberFindOutput.from(devices);
return MemberFindOutput.of(input.email(), devices);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.recyclestudy.member.service.output;

import com.recyclestudy.member.domain.Device;
import com.recyclestudy.member.domain.DeviceIdentifier;
import com.recyclestudy.member.domain.Email;
import java.time.LocalDateTime;
import java.util.List;

public record MemberFindOutput(List<MemberFindElement> elements) {
public record MemberFindOutput(Email email, List<MemberFindElement> elements) {

public static MemberFindOutput from(final List<Device> devices) {
public static MemberFindOutput of(final Email email, final List<Device> devices) {
final List<MemberFindElement> memberFindElements = devices.stream()
.map(device -> new MemberFindElement(device.getMember().getEmail(), device.getCreatedAt()))
.map(device -> new MemberFindElement(device.getIdentifier(), device.getCreatedAt()))
.toList();
return new MemberFindOutput(memberFindElements);
return new MemberFindOutput(email, memberFindElements);
}

public record MemberFindElement(Email email, LocalDateTime createdAt) {
public record MemberFindElement(DeviceIdentifier identifier, LocalDateTime createdAt) {
}
}
1 change: 1 addition & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spring:
properties:
hibernate:
format_sql: true
show_sql: true
open-in-view: false

mail:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void findAllMemberDevices() {
// given
final String email = "test@test.com";
final String identifier = "device-identifier";
final MemberFindOutput output = MemberFindOutput.from(List.of());
final MemberFindOutput output = MemberFindOutput.of(Email.from(email), List.of());

given(memberService.findAllMemberDevices(any())).willReturn(output);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void findAllMemberDevices() {
// then
SoftAssertions.assertSoftly(softAssertions -> {
softAssertions.assertThat(actual.elements()).hasSize(1);
softAssertions.assertThat(actual.elements().getFirst().email()).isEqualTo(input.email());
softAssertions.assertThat(actual.elements().getFirst().identifier()).isEqualTo(input.deviceIdentifier());
});
}

Expand Down