Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
f5895c47
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f5895c47
编写于
6月 16, 2013
作者:
C
Christoph Kutzinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Noting and minor clean up for
6b79233f
上级
6b79233f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
110 addition
and
23 deletion
+110
-23
changelog.html
changelog.html
+3
-0
core/src/main/java/hudson/model/View.java
core/src/main/java/hudson/model/View.java
+9
-8
core/src/test/java/hudson/model/ViewTest.java
core/src/test/java/hudson/model/ViewTest.java
+98
-15
未找到文件。
changelog.html
浏览文件 @
f5895c47
...
@@ -82,6 +82,9 @@ Upcoming changes</a>
...
@@ -82,6 +82,9 @@ Upcoming changes</a>
Core started relying on Java 1.6 as per the agreement in the dev list.
Core started relying on Java 1.6 as per the agreement in the dev list.
If you have a serious objection against it, please let us know
If you have a serious objection against it, please let us know
before we really start relying on 1.6 features.
before we really start relying on 1.6 features.
<li
class=
rfe
>
CLI list-jobs command should list all nested jobs.
(
<a
href=
"https://github.com/jenkinsci/jenkins/pull/793"
>
pull request 793
</a>
)
</ul>
</ul>
</div>
<!--=TRUNK-END=-->
</div>
<!--=TRUNK-END=-->
...
...
core/src/main/java/hudson/model/View.java
浏览文件 @
f5895c47
...
@@ -179,23 +179,24 @@ public abstract class View extends AbstractModelObject implements AccessControll
...
@@ -179,23 +179,24 @@ public abstract class View extends AbstractModelObject implements AccessControll
/**
/**
* Gets all the items recursively contained in this collection in a read-only view.
* Gets all the items recursively contained in this collection in a read-only view.
* <p>
* The default implementation recursively adds the items of all contained Views
* in case this view implements {@link ViewGroup}, which should be enough for most cases.
*
* @since 1.520
* @since 1.520
*/
*/
public
Collection
<
TopLevelItem
>
getAllItems
()
{
public
Collection
<
TopLevelItem
>
getAllItems
()
{
final
Collection
<
TopLevelItem
>
items
=
new
LinkedHashSet
<
TopLevelItem
>(
getItems
()
);
if
(
this
instanceof
ViewGroup
)
{
if
(
this
instanceof
ViewGroup
)
{
final
Collection
<
TopLevelItem
>
items
=
new
LinkedHashSet
<
TopLevelItem
>(
getItems
());
for
(
final
View
view:
((
ViewGroup
)
this
).
getViews
())
{
for
(
View
view:
((
ViewGroup
)
this
).
getViews
())
{
items
.
addAll
(
view
.
getAllItems
());
items
.
addAll
(
view
.
getAllItems
());
}
}
return
Collections
.
unmodifiableCollection
(
items
);
}
else
{
return
getItems
();
}
}
return
Collections
.
unmodifiableCollection
(
items
);
}
}
/**
/**
...
...
core/src/test/java/hudson/model/ViewTest.java
浏览文件 @
f5895c47
package
hudson.model
;
package
hudson.model
;
import
hudson.model.Descriptor.FormException
;
import
hudson.search.SearchIndex
;
import
hudson.search.SearchIndex
;
import
hudson.search.SearchIndexBuilder
;
import
hudson.search.SearchIndexBuilder
;
import
hudson.search.SearchItem
;
import
hudson.search.SearchItem
;
import
hudson.views.ViewsTabBar
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
javax.servlet.ServletException
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
org.mockito.Mockito
;
import
org.mockito.Mockito
;
public
class
ViewTest
{
public
class
ViewTest
{
...
@@ -73,26 +80,21 @@ public class ViewTest {
...
@@ -73,26 +80,21 @@ public class ViewTest {
@Test
@Test
public
void
getAllItems
()
throws
Exception
{
public
void
getAllItems
()
throws
Exception
{
final
CompositeView
rootView
=
Mockito
.
mock
(
CompositeView
.
class
);
final
View
leftView
=
Mockito
.
mock
(
View
.
class
);
final
View
leftView
=
Mockito
.
mock
(
View
.
class
);
final
View
rightView
=
Mockito
.
mock
(
View
.
class
);
final
View
rightView
=
Mockito
.
mock
(
View
.
class
);
CompositeView
rootView
=
new
CompositeView
(
"rootJob"
,
leftView
,
rightView
);
Mockito
.
when
(
rootView
.
getAllItems
()).
thenCallRealMethod
();
Mockito
.
when
(
leftView
.
getAllItems
()).
thenCallRealMethod
();
Mockito
.
when
(
leftView
.
getAllItems
()).
thenCallRealMethod
();
Mockito
.
when
(
rightView
.
getAllItems
()).
thenCallRealMethod
();
Mockito
.
when
(
rightView
.
getAllItems
()).
thenCallRealMethod
();
final
TopLevelItem
rootJob
=
Mockito
.
mock
(
TopLevelItem
.
class
);
final
TopLevelItem
rootJob
=
createJob
(
"rootJob"
);
final
TopLevelItem
leftJob
=
Mockito
.
mock
(
TopLevelItem
.
class
);
final
TopLevelItem
sharedJob
=
createJob
(
"sharedJob"
);
final
TopLevelItem
rightJob
=
Mockito
.
mock
(
TopLevelItem
.
class
);
final
TopLevelItem
sharedJob
=
Mockito
.
mock
(
TopLevelItem
.
class
);
rootView
=
rootView
.
withJobs
(
rootJob
,
sharedJob
);
Mockito
.
when
(
rootJob
.
getDisplayName
()).
thenReturn
(
"rootJob"
);
final
TopLevelItem
leftJob
=
createJob
(
"leftJob"
);
Mockito
.
when
(
leftJob
.
getDisplayName
()).
thenReturn
(
"leftJob"
);
final
TopLevelItem
rightJob
=
createJob
(
"rightJob"
);
Mockito
.
when
(
rightJob
.
getDisplayName
()).
thenReturn
(
"rightJob"
);
Mockito
.
when
(
sharedJob
.
getDisplayName
()).
thenReturn
(
"sharedJob"
);
Mockito
.
when
(
rootView
.
getViews
()).
thenReturn
(
Arrays
.
asList
(
leftView
,
rightView
));
Mockito
.
when
(
rootView
.
getItems
()).
thenReturn
(
Arrays
.
asList
(
rootJob
,
sharedJob
));
Mockito
.
when
(
leftView
.
getItems
()).
thenReturn
(
Arrays
.
asList
(
leftJob
,
sharedJob
));
Mockito
.
when
(
leftView
.
getItems
()).
thenReturn
(
Arrays
.
asList
(
leftJob
,
sharedJob
));
Mockito
.
when
(
rightView
.
getItems
()).
thenReturn
(
Arrays
.
asList
(
rightJob
));
Mockito
.
when
(
rightView
.
getItems
()).
thenReturn
(
Arrays
.
asList
(
rightJob
));
...
@@ -101,10 +103,91 @@ public class ViewTest {
...
@@ -101,10 +103,91 @@ public class ViewTest {
Assert
.
assertArrayEquals
(
expected
,
rootView
.
getAllItems
().
toArray
());
Assert
.
assertArrayEquals
(
expected
,
rootView
.
getAllItems
().
toArray
());
}
}
public
static
abstract
class
CompositeView
extends
View
implements
ViewGroup
{
private
TopLevelItem
createJob
(
String
jobName
)
{
final
TopLevelItem
rootJob
=
Mockito
.
mock
(
TopLevelItem
.
class
);
Mockito
.
when
(
rootJob
.
getDisplayName
()).
thenReturn
(
jobName
);
return
rootJob
;
}
public
static
class
CompositeView
extends
View
implements
ViewGroup
{
protected
CompositeView
(
final
String
name
)
{
private
View
[]
views
;
private
TopLevelItem
[]
jobs
;
protected
CompositeView
(
final
String
name
,
View
...
views
)
{
super
(
name
);
super
(
name
);
this
.
views
=
views
;
}
private
CompositeView
withJobs
(
TopLevelItem
...
jobs
)
{
this
.
jobs
=
jobs
;
return
this
;
}
@Override
public
Collection
<
TopLevelItem
>
getItems
()
{
return
Arrays
.
asList
(
this
.
jobs
);
}
@Override
public
Collection
<
View
>
getViews
()
{
return
Arrays
.
asList
(
this
.
views
);
}
@Override
public
boolean
canDelete
(
View
view
)
{
return
false
;
}
@Override
public
void
deleteView
(
View
view
)
throws
IOException
{
}
@Override
public
View
getView
(
String
name
)
{
return
null
;
}
@Override
public
View
getPrimaryView
()
{
return
null
;
}
@Override
public
void
onViewRenamed
(
View
view
,
String
oldName
,
String
newName
)
{
}
@Override
public
ViewsTabBar
getViewsTabBar
()
{
return
null
;
}
@Override
public
ItemGroup
<?
extends
TopLevelItem
>
getItemGroup
()
{
return
null
;
}
@Override
public
List
<
Action
>
getViewActions
()
{
return
null
;
}
@Override
public
boolean
contains
(
TopLevelItem
item
)
{
return
false
;
}
@Override
public
void
onJobRenamed
(
Item
item
,
String
oldName
,
String
newName
)
{
}
@Override
protected
void
submit
(
StaplerRequest
req
)
throws
IOException
,
ServletException
,
FormException
{
}
@Override
public
Item
doCreateItem
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
return
null
;
}
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录