Skip to content
Permalink
Browse files

#JENKINS-17352 Returned back unit tests, small refactoring

  • Loading branch information
ctapobep committed Mar 28, 2013
1 parent 052d6fe commit b587a8b6619e1f8baa7759d42b3d981dd0481e3f
11 pom.xml
@@ -39,6 +39,17 @@
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>


@@ -62,7 +62,7 @@
* Name of the subview to show when this tree view is selected. May be null/empty.
*/
private String defaultView;
private AvailableColumns columns;
private NestedViewColumns columns;

@DataBoundConstructor
public NestedView(String name) {
@@ -122,7 +122,7 @@ public synchronized void onJobRenamed(Item item, String oldName, String newName)
protected synchronized void submit(StaplerRequest req) throws IOException, ServletException, FormException {
defaultView = Util.fixEmpty(req.getParameter("defaultView"));
if (columns == null) {
columns = new AvailableColumns();
columns = new NestedViewColumns();
}
if (columns.getColumns() == null) {
columns.setColumns(new DescribableList<ListViewColumn, Descriptor<ListViewColumn>>(this));
@@ -158,7 +158,7 @@ public View getDefaultView() {
return isDefault() ? null : getView(defaultView);
}

public AvailableColumns getColumnsToShow() {
public NestedViewColumns getColumnsToShow() {
return columns;
}

@@ -16,11 +16,17 @@
import java.util.List;

/**
* @author sbashkyrtsev
* NestedView delegates things related to optional columns to this class.
*
* @author stanislav bashkirtsev
*/
public class AvailableColumns {
public class NestedViewColumns {
private DescribableList<ListViewColumn, Descriptor<ListViewColumn>> columns;

public void updateFromForm(StaplerRequest req, JSONObject formData, String key) throws IOException, Descriptor.FormException {
columns.rebuildHetero(req, formData, getPossibleColumns(), key);
}

public void setColumns(DescribableList<ListViewColumn, Descriptor<ListViewColumn>> columns) {
this.columns = columns;
}
@@ -29,10 +35,6 @@ public void setColumns(DescribableList<ListViewColumn, Descriptor<ListViewColumn
return columns;
}

public void updateFromForm(StaplerRequest req, JSONObject formData, String key) throws IOException, Descriptor.FormException {
columns.rebuildHetero(req, formData, nestedViewColumns(), key);
}

public boolean isShowStatusColumn() {
return containsColumnWithDescriptor(StatusColumn.DescriptorImpl.class);
}
@@ -41,6 +43,10 @@ public boolean isShowWeatherColumn() {
return containsColumnWithDescriptor(WeatherColumn.DescriptorImpl.class);
}

public static List<Descriptor<ListViewColumn>> getPossibleColumns() {
return extractOptionalColumns(allViewColumns());
}

private boolean containsColumnWithDescriptor(Class<? extends ListViewColumnDescriptor> descriptorClass) {
for (ListViewColumn column : columns) {
if (column.getDescriptor().getClass() == descriptorClass) {
@@ -50,10 +56,6 @@ private boolean containsColumnWithDescriptor(Class<? extends ListViewColumnDescr
return false;
}

public static List<Descriptor<ListViewColumn>> nestedViewColumns() {
return extractOptionalColumns(allViewColumns());
}

private static DescriptorExtensionList<ListViewColumn, Descriptor<ListViewColumn>> allViewColumns() {
return Jenkins.getInstance().getDescriptorList(ListViewColumn.class);
}
@@ -40,7 +40,7 @@ THE SOFTWARE.
</f:entry>
</j:if>
<f:section title="${%Columns}">
<j:invokeStatic var="allColumns" className="hudson.plugins.nested_view.AvailableColumns" method="nestedViewColumns"/>
<j:invokeStatic var="allColumns" className="hudson.plugins.nested_view.NestedViewColumns" method="getPossibleColumns"/>
<f:block>
<f:hetero-list name="columnsToShow" hasHeader="true"
descriptors="${allColumns}"
@@ -43,7 +43,6 @@
* Test interaction of nested-view plugin with Jenkins core.
* @author Alan Harder
*/
@Ignore
public class NestedViewTest extends HudsonTestCase {

public void test() throws Exception {

0 comments on commit b587a8b

Please sign in to comment.
You can’t perform that action at this time.