### Question:
ClouderaManagerLicenseService { void validateClouderaManagerLicense(User user) { if (hasNoLicense(user.getUserCrn())) { LOGGER.error("User '{}' doesn't have a valid cloudera manager license.", user.getUserCrn()); throw new RuntimeException("User doesn't have a valid cloudera manager license."); } }    }### Answer:
@Test public void validWhenLicenseIsNotEmpty() { User user = createUser(); UserManagementProto.Account account = UserManagementProto.Account.newBuilder().setClouderaManagerLicenseKey(LICENSE).build(); when(umsClient.getAccountDetails(USER_CRN, ACCOUNT_ID, Optional.empty())).thenReturn(account); underTest.validateClouderaManagerLicense(user); verify(umsClient).getAccountDetails(USER_CRN, ACCOUNT_ID, Optional.empty()); }
@Test public void invalidWhenLicenseIsEmpty() { User user = createUser(); UserManagementProto.Account account = UserManagementProto.Account.newBuilder().setClouderaManagerLicenseKey("").build(); when(umsClient.getAccountDetails(USER_CRN, ACCOUNT_ID, Optional.empty())).thenReturn(account); expectedException.expect(RuntimeException.class); expectedException.expectMessage("User doesn't have a valid cloudera manager license."); underTest.validateClouderaManagerLicense(user); verify(umsClient).getAccountDetails(USER_CRN, ACCOUNT_ID, Optional.empty()); }