Skip to content
Permalink
Browse files
[JENKINS-38058] pass context when creating 'FolderItem' objects
  • Loading branch information
Manuel Franco committed Sep 8, 2016
1 parent 19aca5e commit 7454e7762a9fe63e6d2e7761b3cf6c090d869311
@@ -39,5 +39,10 @@ public FolderItem(Injector injector, URL url, String name) {
super(injector, url, name);
jobs = new JobsMixIn(this);
}

public FolderItem(PageObject context, URL url, String name) {
super(context, url, name);
jobs = new JobsMixIn(this);
}

}
@@ -65,6 +65,10 @@ public Job(Injector injector, URL url, String name) {
super(injector, url, name);
}

public Job(PageObject context, URL url, String name) {
super(context, url, name);
}

public <T extends Scm> T useScm(Class<T> type) {
ensureConfigPage();

@@ -58,7 +58,14 @@ public Object call() throws Exception {
}

public <T extends TopLevelItem> T get(Class<T> type, String name) {
return newInstance(type, injector, url("job/%s/", name), name);
try {
assert getContext() != null;
return newInstance(type, getContext(), url("job/%s/", name), name);
} catch (AssertionError e) {
// will get here either if the contructor with 'context' parameter
// was not found or if we have no context
return newInstance(type, injector, url("job/%s/", name), name);
}
}

public FreeStyleJob create() {
@@ -115,4 +115,8 @@ public Control control(By selector) {
public String toString() {
return String.format("%s(%s)", getClass().getSimpleName(), url);
}

protected PageObject getContext() {
return context;
}
}
@@ -28,6 +28,11 @@ public TopLevelItem(Injector injector, URL url, String name) {
this.name = name;
}

public TopLevelItem(PageObject context, URL url, String name) {
super(context, url);
this.name = name;
}

/**
* Renames the job. Opens the configuration section, sets the name and saves the form. Finally the rename is
* confirmed.

0 comments on commit 7454e77

Please sign in to comment.