### Question:
PasswordService { @VisibleForTesting Optional<Instant> calculateExpirationTime(String actorCrn, String accountId) { LOGGER.debug("calculating expiration time for password in account {}", accountId); UserManagementProto.Account account = umsClient.getAccountDetails(INTERNAL_ACTOR_CRN, accountId, MDCUtils.getRequestId()); if (account.hasPasswordPolicy()) { long maxLifetime = account.getPasswordPolicy().getWorkloadPasswordMaxLifetime(); if (maxLifetime != 0L) { LOGGER.debug("Calculating password expiration by adding lifetime '{}' to current time", maxLifetime); return Optional.of(clock.getCurrentInstant().plusMillis(maxLifetime)); } else { LOGGER.debug("Password policy lifetime is {}. Using max expiration time", maxLifetime); return Optional.empty(); } } else { LOGGER.debug("Account {} does not have a password policy. Using max expiration time for password", accountId); return Optional.empty(); } }  Operation setPassword(String accountId, String actorCrn, String userCrn, String password, Set<String> environmentCrnFilter); Operation setPasswordWithCustomPermissionCheck(String accountId, String actorCrn, String userCrn,
            String password, Set<String> environmentCrnFilter, AuthorizationResourceAction action);  }### Answer:
@Test void testCalculateExpirationTimeNoPasswordPolicy() { UserManagementProto.Account account = UserManagementProto.Account.newBuilder().build(); when(grpcUmsClient.getAccountDetails(eq(INTERNAL_ACTOR_CRN), eq(ACCOUNT_ID), any())).thenReturn(account); assertEquals(Optional.empty(), underTest.calculateExpirationTime(INTERNAL_ACTOR_CRN, ACCOUNT_ID)); }
@Test void testCalculateExpirationTime0PasswordPolicy() { UserManagementProto.Account account = UserManagementProto.Account.newBuilder() .setPasswordPolicy(UserManagementProto.WorkloadPasswordPolicy.newBuilder() .setWorkloadPasswordMaxLifetime(0) .build()) .build(); when(grpcUmsClient.getAccountDetails(eq(INTERNAL_ACTOR_CRN), eq(ACCOUNT_ID), any())).thenReturn(account); assertEquals(Optional.empty(), underTest.calculateExpirationTime(INTERNAL_ACTOR_CRN, ACCOUNT_ID)); }
@Test void testCalculateExpirationTimePasswordPolicy() { long lifetime = 18276435L; UserManagementProto.Account account = UserManagementProto.Account.newBuilder() .setPasswordPolicy(UserManagementProto.WorkloadPasswordPolicy.newBuilder() .setWorkloadPasswordMaxLifetime(lifetime) .build()) .build(); when(clock.getCurrentInstant()).thenReturn(Instant.ofEpochMilli(MOCK_TIME)); when(grpcUmsClient.getAccountDetails(eq(INTERNAL_ACTOR_CRN), eq(ACCOUNT_ID), any())).thenReturn(account); assertEquals(Optional.of(Instant.ofEpochMilli(MOCK_TIME + lifetime)), underTest.calculateExpirationTime(INTERNAL_ACTOR_CRN, ACCOUNT_ID)); }