### Question:
DefaultProviderTaskPropertiesAccessor implements ProviderTaskPropertiesAccessor { @Override public void setTaskProperty(Long configId, String taskName, String propertyKey, String propertyValue) throws AlertDatabaseConstraintException { if (null == configId || StringUtils.isBlank(taskName) || StringUtils.isBlank(propertyKey) || StringUtils.isBlank(propertyValue)) { throw new AlertDatabaseConstraintException("All fields are required to save a task property"); } ProviderTaskPropertiesEntity taskPropertyToSave = new ProviderTaskPropertiesEntity(configId, taskName, propertyKey, propertyValue); providerTaskPropertiesRepository.save(taskPropertyToSave); } @Autowired  DefaultProviderTaskPropertiesAccessor(ProviderTaskPropertiesRepository providerTaskPropertiesRepository); @Override Optional<String> getTaskProperty(String taskName, String propertyKey); @Override void setTaskProperty(Long configId, String taskName, String propertyKey, String propertyValue);  }### Answer:
@Test public void setTaskPropertyExceptionTest() throws Exception { DefaultProviderTaskPropertiesAccessor providerTaskPropertiesAccessor = new DefaultProviderTaskPropertiesAccessor(providerTaskPropertiesRepository); try { providerTaskPropertiesAccessor.setTaskProperty(null, "", "", ""); fail(); } catch (AlertDatabaseConstraintException e) { assertNotNull(e); } }
@Test public void setTaskPropertyTest() throws Exception { final Long newConfigId = 2L; final String newTaskName = "taskName-new"; final String newPropertyName = "propertyName-new"; final String newValue = "value-new"; DefaultProviderTaskPropertiesAccessor providerTaskPropertiesAccessor = new DefaultProviderTaskPropertiesAccessor(providerTaskPropertiesRepository); providerTaskPropertiesAccessor.setTaskProperty(newConfigId, newTaskName, newPropertyName, newValue); Optional<ProviderTaskPropertiesEntity> providerTaskPropertiesEntityOptional = providerTaskPropertiesRepository.findByTaskNameAndPropertyName(newTaskName, newPropertyName); assertTrue(providerTaskPropertiesEntityOptional.isPresent()); ProviderTaskPropertiesEntity providerTaskPropertiesEntity = providerTaskPropertiesEntityOptional.get(); assertEquals(newConfigId, providerTaskPropertiesEntity.getProviderConfigId()); assertEquals(newTaskName, providerTaskPropertiesEntity.getTaskName()); assertEquals(newPropertyName, providerTaskPropertiesEntity.getPropertyName()); assertEquals(newValue, providerTaskPropertiesEntity.getValue()); }