Skip to content

Commit

Permalink
Fixed #174 An error happen when i get the node List
Browse files Browse the repository at this point in the history
 o Fixed API accordingly to the occured error.
  • Loading branch information
khmarbaise committed Jul 25, 2016
2 parents ea911df + e8059c9 commit e670edd
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 18 deletions.
21 changes: 21 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ public class JenkinsServer {
public void deleteJob(FolderJob folder, String jobName) throws IOException;
}
```
[Fixed issue 174][issue-174]

jenkins.getComputerSet().getComputer() produced an error.
Changed getComputer() into getComputers() cause it returns
a list an not only a single computer.
Based on the above problem the `Executor` needed to be changed to
represent the correct data which is being returned.

```java
public class ComputerSet {
public List<ComputerWithDetails> getComputers();
}
```

```java
public class Executor {
public Job getCurrentExecutable();
public Job getCurrentWorkUnit();
}
```

[Changing getLocalContext(), setLocalContext()][pull-163]

Expand Down Expand Up @@ -541,6 +561,7 @@ TestReport testReport = mavenJob.getLastSuccessfulBuild().getTestReport();
[issue-169]: https://github.com/jenkinsci/java-client-api/issues/169
[issue-168]: https://github.com/jenkinsci/java-client-api/issues/168
[issue-172]: https://github.com/jenkinsci/java-client-api/issues/172
[issue-174]: https://github.com/jenkinsci/java-client-api/issues/174
[pull-123]: https://github.com/jenkinsci/java-client-api/pull/123
[pull-149]: https://github.com/jenkinsci/java-client-api/pull/149
[pull-158]: https://github.com/jenkinsci/java-client-api/pull/158
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void beforeMethod()
public void shouldTriggerJobTest()
throws IOException
{
ComputerWithDetails computerWithDetailsAfterStarting = jenkinsServer.getComputerSet().getComputer().get( 0 );
ComputerWithDetails computerWithDetailsAfterStarting = jenkinsServer.getComputerSet().getComputers().get( 0 );
assertThat( computerWithDetailsAfterStarting.getOffline() ).isFalse();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public void beforeMethod()
public void shouldTriggerJobTest()
throws IOException
{
ComputerWithDetails computerWithDetails = jenkinsServer.getComputerSet().getComputer().get( 0 );
ComputerWithDetails computerWithDetails = jenkinsServer.getComputerSet().getComputers().get( 0 );
computerWithDetails.toggleOffline();

ComputerWithDetails computerWithDetailsAfterStarting = jenkinsServer.getComputerSet().getComputer().get( 0 );
ComputerWithDetails computerWithDetailsAfterStarting = jenkinsServer.getComputerSet().getComputers().get( 0 );

assertThat( computerWithDetailsAfterStarting.getOffline() ).isFalse();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void beforeMethod()
@Test
public void shouldGetNameOfMasterNode()
{
List<ComputerWithDetails> computers = computerSet.getComputer();
List<ComputerWithDetails> computers = computerSet.getComputers();
assertThat( computers ).hasSize( 1 );
assertThat( computers.get( 0 ).getDisplayName() ).isEqualTo( "master" );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class NoExecutorStartedGetComputersWithDetailsIT
public void beforeMethod()
throws IOException
{
computerWithDetails = jenkinsServer.getComputerSet().getComputer().get( 0 );
computerWithDetails = jenkinsServer.getComputerSet().getComputers().get( 0 );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class NoExecutorStartedGetOfflineCauseIT
public void beforeMethod()
throws IOException
{
offlineCause = jenkinsServer.getComputerSet().getComputer().get( 0 ).getOfflineCause();
offlineCause = jenkinsServer.getComputerSet().getComputers().get( 0 ).getOfflineCause();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import java.util.List;

import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

public class ComputerSet extends BaseModel {
private int busyExecutors;
Expand Down Expand Up @@ -42,7 +40,7 @@ public void setTotalExecutors(int totalExecutors) {
this.totalExecutors = totalExecutors;
}

public List<ComputerWithDetails> getComputer() {
public List<ComputerWithDetails> getComputers() {
return Lists.transform( computer, new Function<ComputerWithDetails, ComputerWithDetails>() {
@Override
public ComputerWithDetails apply(ComputerWithDetails computerWithDetails) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@
*/
public class Executor {

private String currentExecutable;
private Job currentExecutable;
// in XSD it's a reference to a class
private String currentWorkUnit;
private Job currentWorkUnit;
private Boolean idle;
private Boolean likelyStuck;
private int number;
private int progress;

public String getCurrentExecutable() {
public Job getCurrentExecutable() {
return currentExecutable;
}

public void setCurrentExecutable(String currentExecutable) {
public void setCurrentExecutable(Job currentExecutable) {
this.currentExecutable = currentExecutable;
}

public String getCurrentWorkUnit() {
public Job getCurrentWorkUnit() {
return currentWorkUnit;
}

public void setCurrentWorkUnit(String currentWorkUnit) {
public void setCurrentWorkUnit(Job currentWorkUnit) {
this.currentWorkUnit = currentWorkUnit;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void shouldGetTotalExecutors() throws JAXBException, IOException, Documen
public void shouldGetComputerWithDetailsAndExecutors() throws IOException {
Jenkins ji = jenkinsRule.getInstance();

List<ComputerWithDetails> computerSet = jenkinsServer.getComputerSet().getComputer();
List<ComputerWithDetails> computerSet = jenkinsServer.getComputerSet().getComputers();
ComputerWithDetails computerWithDetails = computerSet.get(0);
assertThat(computerWithDetails.getExecutors()).isNotNull();
assertThat(computerWithDetails.getNumExecutors()).isEqualTo(ji.getNumExecutors());
Expand All @@ -41,10 +41,10 @@ public void shouldGetComputerWithDetailsAndExecutors() throws IOException {

@Test
public void shouldTrunFromOnlineToOffline() throws IOException {
ComputerWithDetails computerWithDetails = jenkinsServer.getComputerSet().getComputer().get( 0 );
ComputerWithDetails computerWithDetails = jenkinsServer.getComputerSet().getComputers().get( 0 );
computerWithDetails.toggleOffline(true);

ComputerWithDetails computerWithDetailsAfterStarting = jenkinsServer.getComputerSet().getComputer().get( 0 );
ComputerWithDetails computerWithDetailsAfterStarting = jenkinsServer.getComputerSet().getComputers().get( 0 );

assertThat( computerWithDetailsAfterStarting.getOffline() ).isTrue();
}
Expand Down

0 comments on commit e670edd

Please sign in to comment.