### Question:
ActorUtil { public String getActorCrn(ActorBase actorBase) { String actorCrn; if (actorBase instanceof ActorCrn) { ActorCrn actor = (ActorCrn) actorBase; actorCrn = actor.getActorCrn(); } else if (actorBase instanceof ActorService) { actorCrn = INTERNAL_ACTOR_CRN; } else { throw new IllegalArgumentException("Actor has an invalid class: " + actorBase.getClass().getName()); } return actorCrn; }  String getActorCrn(ActorBase actorBase);  }### Answer:
@Test void getActorCrnFromActor() { ActorCrn actorCrn = ActorCrn.builder().withActorCrn(MY_CRN).build(); String crn = underTest.getActorCrn(actorCrn); assertThat(crn).isEqualTo(MY_CRN); }
@Test void getActorCrnFromService() { ActorService actorService = ActorService.builder().withActorServiceName("datahub").build(); String crn = underTest.getActorCrn(actorService); assertThat(crn).isEqualTo(INTERNAL_ACTOR_CRN); }
@Test void getUnrecognizedClassThrows() { class Unknown extends ActorBase { } Unknown unknown = new Unknown(); assertThatThrownBy(() -> underTest.getActorCrn(unknown)).isInstanceOf(IllegalArgumentException.class); }