Newer
Older
test-sample / src / main / java / com / example / testsample / SampleAppService.java
yhornisse on 9 Oct 2023 929 bytes add test sample
package com.example.testsample;

import org.jetbrains.annotations.VisibleForTesting;
import org.springframework.stereotype.Service;

@Service
public class SampleAppService {

  private final Sample1DomainService sample1DomainService;
  private final Sample2DomainService sample2DomainService;

  public SampleAppService(
      final Sample1DomainService sample1DomainService,
      final Sample2DomainService sample2DomainService) {
    this.sample1DomainService = sample1DomainService;
    this.sample2DomainService = sample2DomainService;
  }

  public SampleResponse hoge() {
    final var e1 = sample1DomainService.findById(1L);
    final var e2 = sample2DomainService.findById(2L);
    return convert(e1, e2);
  }

  @VisibleForTesting
  static SampleResponse convert(
      final Sample1Entity sample1,
      final Sample2Entity sample2) {
    return new SampleResponse(sample1.id(), sample1.name(), sample2.name());
  }
}