下面列出了怎么用hudson.model.Api的API类实例代码及写法,或者点击链接到github查看源代码。
@Test
void shouldCreateCompleteApi() {
Run<?, ?> owner = mock(Run.class);
List<ResultAction> actions = Lists.fixedSize.of(
createAction(JobStubs.SPOT_BUGS_ID, JobStubs.SPOT_BUGS_NAME, SIZE),
createAction(JobStubs.CHECK_STYLE_NAME, JobStubs.CHECK_STYLE_NAME, SIZE)
);
when(owner.getActions(any())).thenAnswer(i -> actions);
AggregationAction action = new AggregationAction();
action.onLoad(owner);
Api api = action.getApi();
AggregationApi aggregationApi = (AggregationApi) api.bean;
assertThat(aggregationApi.getTools()).hasSize(2);
List<ToolApi> actually = action.getTools();
assertThat(actually).hasSize(2);
}
/**
* Gets the remote API for this action. Depending on the path, a different result is selected.
*
* @return the remote API
*/
public Api getApi() {
if (getUrl().endsWith(labelProvider.getId())) {
return new Api(new AnalysisResultApi(result));
}
return new Api(new ReportApi(getIssues(), result.getBlames()));
}
@Test
void shouldReturnAggregationApi() {
Run<?, ?> owner = mock(Run.class);
when(owner.getActions(any())).thenReturn(Collections.emptyList());
AggregationAction action = new AggregationAction();
action.onAttached(owner);
Api api = action.getApi();
assertThat(api.bean).isInstanceOf(AggregationApi.class);
}
/** Remote API access. */
public Api getApi() {
return new Api(this);
}
public final Api getApi() {
return new Api(this);
}
public final Api getApi() {
return new Api(this);
}
public final Api getApi() {
return new Api(this);
}
public Api getApi() {
return new Api(this);
}
public Api getApi() {
return new Api(this);
}
public Api getApi() {
return new Api(this);
}
/**
* Returns the {@link Api} for the plugin.
*
* @return Api for the plugin.
* @see <a href="https://wiki.jenkins.io/display/JENKINS/Exposing+data+to+the+remote+API">
* Wiki Article on exposing data to remote API</a>.
*/
public Api getApi() {
return new Api(this);
}
/**
* Gets the remote API for this action. Depending on the path, a different result is selected.
*
* @return the remote API
*/
public Api getApi() {
return new Api(new AggregationApi(findActions()));
}
/**
* Exposes this object through the remote API.
*
* @return the api for this test object.
*/
public abstract Api getApi();