### Question:
UserAggregate extends AbstractRootAggregate<UserDto> { public static UserAggregate of(UserDto userDto) { return new UserAggregate(userDto); } private  UserAggregate(String id); private  UserAggregate(UserDto userDto); @Override Aggregate<UserDto> apply(DomainEvent event); @Override UserDto state(); static UserAggregate of(UserDto userDto); static UserAggregate of(String id);  }### Answer:
@Test void createUser_nullCommand() { Assertions.assertFalse(UserAggregate.of(UUID.randomUUID().toString()).validate(null).isFailure()); }
@Test void ofTest() { UserDocument userDocument = new UserDocument(UUID.randomUUID().toString(), FIST_NAME, LAST_NAME, 1L, CREATED_AT, null); UserDto userDto = UserMapper.FN.mapToDto.apply(userDocument); UserAggregate subject = UserAggregate.of(userDto); Try<ValidateResult> contactInforesult = subject.validate(CreateContactInfo.builder().email("test@test.com").build()); contactInforesult.toOptional().ifPresent(r -> r.events().forEach(subject::apply)); UserDto result = subject.state(); ContactInfoDto contactInfoState = result.contactInformation().get(); Assertions.assertEquals(userDto.id(), userDocument.getId()); Assertions.assertEquals(userDto.version(), userDocument.getVersion()); Assertions.assertEquals(userDto.firstName(), userDocument.getFirstName()); Assertions.assertEquals(userDto.lastName(), userDocument.getLastName()); Assertions.assertEquals(userDto.createdAt(), userDocument.getCreatedAt()); Assertions.assertEquals("test@test.com", contactInfoState.email().get()); }