### Question:
UrnPropertiesReader { public static String getVariable(String variableName, DelegateExecution execution) { Object value = execution.getVariable(variableName); if (value != null) { logger.trace("Retrieved value for the URN variable, {}, from the execution object: {}", variableName, String.valueOf(value)); return String.valueOf(value); } String variableValue = null; if (environment != null && environment.getProperty(variableName) != null) { variableValue = environment.getProperty(variableName); logger.trace("Retrieved value for the URN variable, {}, from the environment variable: {}", variableName, variableValue); execution.setVariable(variableName, variableValue); return variableValue; } return variableValue; }  @Autowired void setEnvironment(Environment environment); static String getVariable(String variableName, DelegateExecution execution); static String getVariable(String variableName, DelegateExecution execution, String defaultValue); static String getVariable(String variableName); static String[] getVariablesArray(String variableName); static String getVariable(String variableName, String defaultValue);  }### Answer:
@Test public void testGetVariableFromExecution() { ExecutionEntity mockExecution = mock(ExecutionEntity.class); when(mockExecution.getVariable("testKey")).thenReturn("testValue"); String value = UrnPropertiesReader.getVariable("testKey", mockExecution); Assert.assertEquals("testValue", value); verify(mockExecution).getVariable("testKey"); verify(mockExecution, never()).setVariable("testKey", value); }
@Test public void testGetVariableNotExist() { ExecutionEntity mockExecution = mock(ExecutionEntity.class); String value = UrnPropertiesReader.getVariable("notExist", mockExecution); Assert.assertEquals(null, value); verify(mockExecution).getVariable("notExist"); verify(mockExecution, never()).setVariable("notExist", value); }