public enum AdAccountType {
BUSINESS,
INDIVIDUAL
}
@Getter
@ToString
@AllArgsConstructor
public class AdAccountTO {
private Long id;
private String name;
private AdAccountType adAccountType;
}
@Getter
@ToString(callSuper = true)
public class BusinessAdAccountTO extends AdAccountTO {
private String companyName;
@Builder
private BusinessAdAccountTO(Long id, String name, String companyName) {
super(id, name, AdAccountType.BUSINESS);
this.companyName = companyName;
}
}
@Getter
@ToString(callSuper = true)
public class IndividualAdAccountTO extends AdAccountTO {
private String masterName;
@Builder
private IndividualAdAccountTO(Long id, String name, String masterName) {
super(id, name, AdAccountType.INDIVIDUAL);
this.masterName = masterName;
}
}
테스트
@Slf4j
class BusinessAdAccountTOTest {
@Test
public void buildTest() {
BusinessAdAccountTO businessAdAccountTO = BusinessAdAccountTO.builder()
.id(1L)
.name("robin")
.companyName("kakao")
.build();
assertThat(businessAdAccountTO.getId()).as("id").isEqualTo(1L);
assertThat(businessAdAccountTO.getName()).as("name").isEqualTo("robin");
assertThat(businessAdAccountTO.getAdAccountType()).as("type").isEqualTo(AdAccountType.BUSINESS);
assertThat(businessAdAccountTO.getCompanyName()).as("companyName").isEqualTo("kakao");
}
}
'백엔드기술 > 개발언어' 카테고리의 다른 글
JDK17 이제는 AdoptOpenJDK 대신 Eclipse Temurin 사용 (0) | 2021.10.17 |
---|---|
Java 버젼별 비교 정리 (0) | 2015.03.30 |
Django 에서 복합키 업데이트시 주의사항 (0) | 2014.03.12 |