use of org.hudsonci.api.model.IProjectProperty in project hudson-2.x by hudson.
the class MatrixProjectTest method testDoResetProjectPropertyOneProperty.
@Test
public void testDoResetProjectPropertyOneProperty() throws IOException {
final IProjectProperty filterProperty = createMock(StringProjectProperty.class);
String input = MatrixProject.TOUCH_STONE_COMBINATION_FILTER_PROPERTY_NAME;
MatrixProject project = new MatrixProjectMock("parent") {
public IProjectProperty getProperty(String key) {
if (MatrixProject.TOUCH_STONE_COMBINATION_FILTER_PROPERTY_NAME.equals(key)) {
return filterProperty;
} else {
return null;
}
}
};
filterProperty.resetValue();
replay(filterProperty);
project.doResetProjectProperty(input);
verify(filterProperty);
}
use of org.hudsonci.api.model.IProjectProperty in project hudson-2.x by hudson.
the class CascadingUtil method getProjectProperty.
/**
* Returns project property by specified key.
*
* @param currentJob job that should be analyzed.
* @param key key.
* @param clazz required property class.
* If class is not null and property was not found, property of given class will be created.
* @return {@link org.hudsonci.api.model.IProjectProperty} instance or null.
* @throws IllegalArgumentException if currentJob is null.
*/
@SuppressWarnings("unchecked")
public static <T extends IProjectProperty> T getProjectProperty(ICascadingJob currentJob, String key, Class<T> clazz) {
if (currentJob == null) {
throw new IllegalArgumentException("Job cannot be null");
}
IProjectProperty t = (IProjectProperty) currentJob.getProjectProperties().get(key);
if (null == t && null != clazz) {
try {
t = clazz.getConstructor(ICascadingJob.class).newInstance(currentJob);
t.setKey(key);
currentJob.putProjectProperty(key, t);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
return (T) t;
}
use of org.hudsonci.api.model.IProjectProperty in project hudson-2.x by hudson.
the class Job method clearCascadingProject.
/**
* Removes cascading project data, marks all project properties as non-overridden and saves configuration
*
* @throws java.io.IOException if configuration couldn't be saved.
*/
private void clearCascadingProject() throws IOException {
CascadingUtil.unlinkProjectFromCascadingParents(cascadingProject, name);
this.cascadingProject = null;
this.cascadingProjectName = null;
for (IProjectProperty property : jobProperties.values()) {
property.onCascadingProjectChanged();
}
}
use of org.hudsonci.api.model.IProjectProperty in project hudson-2.x by hudson.
the class Job method getCascadingJobProperties.
/**
* @return list of cascading {@link JobProperty} instances. Includes {@link ParametersDefinitionProperty} and
* children of {@link JobProperty} from external plugins.
*/
private CopyOnWriteList getCascadingJobProperties() {
CopyOnWriteList result = new CopyOnWriteList();
CopyOnWriteList<ParametersDefinitionProperty> definitionProperties = getParameterDefinitionProperties();
if (null != cascadingJobProperties && !cascadingJobProperties.isEmpty()) {
for (String key : cascadingJobProperties) {
IProjectProperty projectProperty = CascadingUtil.getProjectProperty(this, key);
Object value = projectProperty.getValue();
if (null != value) {
result.add(value);
}
}
}
if (null != definitionProperties && !definitionProperties.isEmpty()) {
result.addAll(definitionProperties.getView());
}
return result;
}
use of org.hudsonci.api.model.IProjectProperty in project hudson-2.x by hudson.
the class Job method buildProjectProperties.
/**
* Initializes and builds project properties. Also converts legacy properties to IProjectProperties.
* Subclasses should inherit and override this behavior.
*
* @throws IOException if any.
*/
protected void buildProjectProperties() throws IOException {
initProjectProperties();
for (Map.Entry<String, IProjectProperty> entry : jobProperties.entrySet()) {
IProjectProperty property = entry.getValue();
property.setKey(entry.getKey());
property.setJob(this);
}
convertLogRotatorProperty();
convertJobProperties();
}
Aggregations