### Question:
StackDownscaleValidatorService { public void checkUserHasRightToTerminateInstance(String owner, String userId, Long stackId) { if (!Objects.equals(owner, userId)) { throw new AccessDeniedException(String.format("Private stack (%s) is only modifiable by the owner.", stackId)); } }  void checkInstanceIsTheClusterManagerServerOrNot(String instancePublicIp, InstanceMetadataType metadataType); void checkUserHasRightToTerminateInstance(String owner, String userId, Long stackId); void checkClusterInValidStatus(Cluster cluster);  }### Answer:
@Test public void testCheckUserHasRightToTerminateInstanceMethodWhenOwnerAndUserIdIsSameThenNoException() { underTest.checkUserHasRightToTerminateInstance("same", "same", STACK_ID); }
@Test public void testCheckUserHasRightToTerminateInstanceMethodWhenUserIdAndOwnerAreNotTheSameThenExceptionWouldInvoke() { expectedException.expect(AccessDeniedException.class); expectedException.expectMessage(ACCESS_DENIED_EXCEPTION_MESSAGE); underTest.checkUserHasRightToTerminateInstance("something here", "something else here", STACK_ID); }