AggregateRoot { protected <S extends EntityState, A extends AggregatePart<I, S, ?, ?>> S partState(Class<S> partStateClass) { AggregatePartRepository<I, A, ?> repo = repositoryOf(partStateClass); AggregatePart<I, S, ?, ?> aggregatePart = repo.loadOrCreate(id()); S partState = aggregatePart.state(); return partState; } protected  AggregateRoot(BoundedContext context, I id); I id();  }
@Test @DisplayName("obtain part state by its class") void returnPartStateByClass() { EntityState definitionPart = aggregateRoot.partState(ProjectDefinition.class); assertNotNull(definitionPart); EntityState lifeCyclePart = aggregateRoot.partState(ProjectLifecycle.class); assertNotNull(lifeCyclePart); }