Source:
public void testVariables() throws GitLabApiException { assumeNotNull(testProject); String key = TEST_VARIABLE_KEY_PREFIX + HelperUtils.getRandomInt() + "_" + HelperUtils.getRandomInt(); String value = "TEST_VARIABLE_VALUE_" + HelperUtils.getRandomInt() + "_" + HelperUtils.getRandomInt(); Variable variable = gitLabApi.getProjectApi().createVariable(testProject, key, value, null, null, null); assertNotNull(variable); assertEquals(key, variable.getKey()); assertEquals(value, variable.getValue()); assertFalse(variable.getMasked()); Stream<Variable> variables = gitLabApi.getProjectApi().getVariablesStream(testProject); assertNotNull(variables); Variable matchingVariable = variables.filter(v -> v.getKey().equals(key)).findAny().orElse(null); assertNotNull(matchingVariable); assertEquals(key, matchingVariable.getKey()); assertEquals(value, matchingVariable.getValue()); assertFalse(matchingVariable.getProtected()); assertNull(matchingVariable.getEnvironmentScope()); gitLabApi.getProjectApi().updateVariable(testProject, key, "NONE", true, "DEV"); variable = gitLabApi.getProjectApi().getVariable(testProject, key); assertNotNull(variable); assertEquals(key, variable.getKey()); assertEquals("NONE", variable.getValue()); assertTrue(variable.getProtected()); gitLabApi.getProjectApi().updateVariable(testProject, key, value, true, true, "DEV"); variable = gitLabApi.getProjectApi().getVariable(testProject, key); assertNotNull(variable); assertEquals(key, variable.getKey()); assertEquals("NONE", variable.getValue()); assertTrue(variable.getMasked()); assertTrue(variable.getProtected()); gitLabApi.getProjectApi().deleteVariable(testProject, key); variables = gitLabApi.getProjectApi().getVariablesStream(testProject); assertNotNull(variables); matchingVariable = variables.filter(v -> v.getKey().equals(key)).findAny().orElse(null); assertNull(matchingVariable); }

Target:
public void testVariables() throws GitLabApiException { assumeNotNull(testProject); String key = TEST_VARIABLE_KEY_PREFIX + HelperUtils.getRandomInt() + "_" + HelperUtils.getRandomInt(); String value = "TEST_VARIABLE_VALUE_" + HelperUtils.getRandomInt() + "_" + HelperUtils.getRandomInt(); Variable variable = gitLabApi.getProjectApi().createVariable(testProject, key, value, null, null, null); assertNotNull(variable); assertEquals(key, variable.getKey()); assertEquals(value, variable.getValue()); Stream<Variable> variables = gitLabApi.getProjectApi().getVariablesStream(testProject); assertNotNull(variables); Variable matchingVariable = variables.filter(v -> v.getKey().equals(key)).findAny().orElse(null); assertNotNull(matchingVariable); assertEquals(key, matchingVariable.getKey()); assertEquals(value, matchingVariable.getValue()); assertFalse(matchingVariable.getProtected()); assertNull(matchingVariable.getEnvironmentScope()); gitLabApi.getProjectApi().updateVariable(testProject, key, "NONE", true, "DEV"); variable = gitLabApi.getProjectApi().getVariable(testProject, key); assertNotNull(variable); assertEquals(key, variable.getKey()); assertEquals("NONE", variable.getValue()); assertTrue(variable.getProtected()); gitLabApi.getProjectApi().updateVariable(testProject, key, value, true, true, "DEV"); variable = gitLabApi.getProjectApi().getVariable(testProject, key); assertNotNull(variable); assertEquals(key, variable.getKey()); assertEquals("NONE", variable.getValue()); assertTrue(variable.getMasked()); assertTrue(variable.getProtected()); gitLabApi.getProjectApi().deleteVariable(testProject, key); variables = gitLabApi.getProjectApi().getVariablesStream(testProject); assertNotNull(variables); matchingVariable = variables.filter(v -> v.getKey().equals(key)).findAny().orElse(null); assertNull(matchingVariable); }