### Question:
DefaultPermissionNameResolver implements PermissionNameResolver { @Override public <R extends NotificationDto<?>> Optional<String> resolve(final R creationRequest) { Assert.notNull(creationRequest, "Null was passed as an argument for parameter 'creationRequest'."); final String permissionNameKey = permissionNameKey(creationRequest); final String permissionName = permissionMappings.getProperty(permissionNameKey(creationRequest)); if (StringUtils.isBlank(permissionName)) { logger.warn("No permission was configured for '{}' notification.", permissionNameKey); return Optional.empty(); } return Optional.of(permissionName); } DefaultPermissionNameResolver(final Properties permissionMappings); @Override Optional<String> resolve(final R creationRequest);  }### Answer:
@Test public void resolveWithIllegalArguments() { assertThatThrownBy(() -> permissionNameResolver.resolve(null)) .isInstanceOf(IllegalArgumentException.class); }
@Test public void resolveForTemplatedNotificationCreation() { final EmailNotificationDto notificationDto = new EmailNotificationDto(); notificationDto.setTemplateName(uuid()); final String permissionName = uuid(); expect(permissionMappings.getProperty(notificationDto.getTemplateName())).andReturn(permissionName); replayAll(); assertThat(permissionNameResolver.resolve(notificationDto).orElseThrow(() -> new AssertionError("PermissionName should be present!"))) .isEqualTo(permissionName); verifyAll(); }
@Test public void resolveForNonTemplatedNotificationCreation() { final EmailNotificationDto notificationDto = new EmailNotificationDto(); final String permissionName = uuid(); expect(permissionMappings.getProperty("nontemplated")).andReturn(permissionName); replayAll(); assertThat(permissionNameResolver.resolve(notificationDto).orElseThrow(() -> new AssertionError("PermissionName should be present!"))) .isEqualTo(permissionName); verifyAll(); }
@Test public void resolveMissingPermissionMapping() { final EmailNotificationDto notificationDto = new EmailNotificationDto(); notificationDto.setTemplateName(uuid()); expect(permissionMappings.getProperty(notificationDto.getTemplateName())).andReturn(null); replayAll(); assertThat(permissionNameResolver.resolve(notificationDto)).isEmpty(); verifyAll(); }