Skip to content

Commit

Permalink
Revert "Fixed deprecations"
Browse files Browse the repository at this point in the history
  • Loading branch information
patbos committed Jul 14, 2015
1 parent 29a053d commit 18e2533
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 147 deletions.
33 changes: 2 additions & 31 deletions src/main/java/se/diabol/jenkins/pipeline/DeliveryPipelineView.java
Expand Up @@ -33,7 +33,6 @@
import hudson.model.View;
import hudson.model.ViewDescriptor;
import hudson.model.ViewGroup;
import hudson.model.listeners.ItemListener;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import jenkins.model.Jenkins;
Expand Down Expand Up @@ -255,7 +254,8 @@ public void setEmbeddedCss(String embeddedCss) {
}
}

public void onProjectRenamed(Item item, String oldName, String newName) {
@Override
public void onJobRenamed(Item item, String oldName, String newName) {
if (componentSpecs != null) {
Iterator<ComponentSpec> it = componentSpecs.iterator();
while (it.hasNext()) {
Expand Down Expand Up @@ -352,7 +352,6 @@ public void triggerRebuild(String projectName, String buildId) {
}
AbstractBuild build = project.getBuildByNumber(Integer.parseInt(buildId));

@SuppressWarnings("unchecked")
List<Cause> prevCauses = build.getCauses();
CauseAction causeAction = new CauseAction();
for (Cause cause : prevCauses) {
Expand Down Expand Up @@ -608,32 +607,4 @@ public FormValidation doCheckName(@QueryParameter String value) {

}
}


@Extension
public static class ItemListenerImpl extends ItemListener {

@Override
public void onRenamed(Item item, String oldName, String newName) {
notifyView(item, oldName, newName);
}

@Override
public void onDeleted(Item item) {
notifyView(item, item.getFullName(), null);
}


private void notifyView(Item item, String oldName, String newName) {
Collection<View> views = Jenkins.getInstance().getViews();
for (View view : views) {
if (view instanceof DeliveryPipelineView) {
((DeliveryPipelineView) view).onProjectRenamed(item, oldName, newName);
}
}
}


}

}
Expand Up @@ -75,7 +75,6 @@ public static List<Change> getChanges(AbstractBuild<?, ?> build) {
String changeLink = null;
if (repositoryBrowser != null) {
try {
@SuppressWarnings("unchecked")
URL link = repositoryBrowser.getChangeSetLink(entry);
if (link != null) {
changeLink = link.toExternalForm();
Expand Down
Expand Up @@ -23,7 +23,7 @@

import java.util.List;

import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Objects.toStringHelper;

@ExportedBean(defaultVisibility = AbstractItem.VISIBILITY)
public class Component extends AbstractItem {
Expand All @@ -49,7 +49,6 @@ public String getFirstJob() {
}

@Exported
@SuppressWarnings("unused")
public String getFirstJobUrl() {
return firstJobUrl;
}
Expand Down
Expand Up @@ -85,7 +85,6 @@ public static ManualStep getManualStepLatest(AbstractProject project, AbstractBu
List<AbstractProject> upstreams = getUpstreamManualTriggered(project);
for (int i = 0; i < upstreams.size(); i++) {
AbstractProject upstream = upstreams.get(i);
@SuppressWarnings("unchecked")
AbstractBuild upstreamBuild = BuildUtil.match(upstream.getBuilds(), firstBuild);
if (build == null) {
if (upstreamBuild != null && !upstreamBuild.isBuilding() && !ProjectUtil.isQueued(project, firstBuild)) {
Expand Down
Expand Up @@ -32,7 +32,7 @@
import java.util.Map;
import java.util.Set;

import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Objects.toStringHelper;
import static com.google.common.collect.Lists.newArrayList;

@ExportedBean(defaultVisibility = AbstractItem.VISIBILITY)
Expand Down Expand Up @@ -206,7 +206,10 @@ public List<Pipeline> createPipelineLatest(int noOfPipelines, ItemGroup context)
}
Pipeline pipelineLatest = new Pipeline(getName(), firstProject, "#" + firstProject.getNextBuildNumber(), pipeLineTimestamp,
Trigger.getTriggeredBy(firstProject, null), null,
// Trigger.getTriggeredBy(firstBuild),
// UserInfo.getContributors(firstBuild),
pipelineStages, false);
//pipelineLatest.setChanges(pipelineChanges);
result.add(pipelineLatest);
no--;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/se/diabol/jenkins/pipeline/domain/Stage.java
Expand Up @@ -43,7 +43,7 @@
import java.util.Map;
import java.util.Set;

import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Objects.toStringHelper;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Lists.newArrayList;
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/se/diabol/jenkins/pipeline/domain/Task.java
Expand Up @@ -37,8 +37,6 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static se.diabol.jenkins.pipeline.domain.status.StatusFactory.disabled;
import static se.diabol.jenkins.pipeline.domain.status.StatusFactory.idle;
import static com.google.common.base.MoreObjects.toStringHelper;


@ExportedBean(defaultVisibility = AbstractItem.VISIBILITY)
public class Task extends AbstractItem {
Expand Down Expand Up @@ -217,13 +215,15 @@ private AbstractProject getProject(Task task, ItemGroup context) {

@Override
public String toString() {
return toStringHelper(this)
.add("id", id)
.add("link", link)
.add("testResult", testResult)
.add("status", status)
.add("manueal", manual)
.add("buildId", buildId)
.add("downstreamTasks", downstreamTasks).toString();
final StringBuilder sb = new StringBuilder("Task{");
sb.append("id='").append(id).append('\'');
sb.append(", link='").append(link).append('\'');
sb.append(", testResult=").append(testResult);
sb.append(", status=").append(status);
sb.append(", manual=").append(manual);
sb.append(", buildId='").append(buildId).append('\'');
sb.append(", downstreamTasks=").append(downstreamTasks);
sb.append('}');
return sb.toString();
}
}
Expand Up @@ -106,7 +106,7 @@ public static List<Trigger> getTriggeredBy(AbstractProject project, AbstractBuil
return new ArrayList<Trigger>(result);
}

protected static String getDisplayName(String userName) {
private static String getDisplayName(String userName) {
User user = Jenkins.getInstance().getUser(userName);
if (user != null) {
return user.getDisplayName();
Expand Down
Expand Up @@ -62,7 +62,7 @@ public boolean equals(Object o) {

UserInfo userInfo = (UserInfo) o;

return userInfo.getName().equals(getName());
return userInfo.getName().equals(userInfo.getName());
}

@Override
Expand Down
Expand Up @@ -30,7 +30,6 @@
public class PromotionStatusProvider extends AbstractPromotionStatusProvider {

// Force a classloading error plugin isn't available
@SuppressWarnings("UnusedDeclaration")
static final public Class CLASS = PromotedBuildAction.class;
static final String DEFAULT_ICON_SIZE = "16x16";

Expand Down
Expand Up @@ -32,8 +32,7 @@
public class BPPManualTriggerResolver extends ManualTriggerResolver {

// Force a classloading error plugin isn't available
@SuppressWarnings("unused")
public static final Class CLASS = BuildPipelineTrigger.class;
public static final Class clazz = BuildPipelineTrigger.class;


@Override
Expand Down Expand Up @@ -71,7 +70,6 @@ public List<AbstractProject> getUpstreamManualTriggered(AbstractProject<?, ?> pr
List<AbstractProject> result = new ArrayList<AbstractProject>();
List<AbstractProject> upstreamProjects = project.getUpstreamProjects();
for (AbstractProject upstream : upstreamProjects) {
@SuppressWarnings("unchecked")
DescribableList<Publisher, Descriptor<Publisher>> upstreamPublishersLists = upstream.getPublishersList();
for (Publisher upstreamPub : upstreamPublishersLists) {
if (upstreamPub instanceof BuildPipelineTrigger) {
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/se/diabol/jenkins/pipeline/util/BuildUtil.java
Expand Up @@ -92,8 +92,15 @@ public static AbstractBuild match(RunList<? extends AbstractBuild> runList, Abst


public static boolean equals(AbstractBuild b1, AbstractBuild b2) {
return b1 != null && b2 != null && b1.getProject().getFullName().equals(b2.getProject().getFullName())
&& b1.getNumber() == b2.getNumber();
if (b1 != null && b2 != null) {
if (b1.getProject().getFullName().equals(b2.getProject().getFullName()) && b1.getNumber() == b2.getNumber()) {
return true;
} else {
return false;
}
} else {
return false;
}

}

Expand Down
Expand Up @@ -136,7 +136,6 @@ public static boolean isQueued(AbstractProject project, AbstractBuild firstBuild
return true;
} else {
List<Cause.UpstreamCause> causes = Util.filter(project.getQueueItem().getCauses(), Cause.UpstreamCause.class);
@SuppressWarnings("unchecked")
List<AbstractProject<?,?>> upstreamProjects = project.getUpstreamProjects();
for (AbstractProject<?, ?> upstreamProject : upstreamProjects) {
AbstractBuild upstreamBuild = BuildUtil.match(upstreamProject.getBuilds(), firstBuild);
Expand Down
Expand Up @@ -66,20 +66,15 @@ public class DeliveryPipelineViewTest {
public JenkinsRule jenkins = new JenkinsRule();

@Test
public void testOnJobRenamed() throws Exception {

FreeStyleProject p1 = jenkins.createFreeStyleProject("build1");

@WithoutJenkins
public void testOnJobRenamed() {
List<DeliveryPipelineView.ComponentSpec> componentSpecs = new ArrayList<DeliveryPipelineView.ComponentSpec>();
componentSpecs.add(new DeliveryPipelineView.ComponentSpec("comp1", "build1"));
componentSpecs.add(new DeliveryPipelineView.ComponentSpec("comp2", "build2"));

DeliveryPipelineView view = new DeliveryPipelineView("Test");
view.setComponentSpecs(componentSpecs);
jenkins.getInstance().addView(view);

p1.renameTo("newbuild");

view.onJobRenamed(null, "build1", "newbuild");
assertEquals("newbuild", view.getComponentSpecs().get(0).getFirstJob());
}

Expand All @@ -89,32 +84,24 @@ public void testOnJobRenamed() throws Exception {
public void testOnJobRenamedNoComponentSpecs() {
DeliveryPipelineView view = new DeliveryPipelineView("Test");
//Rename
view.onProjectRenamed(null, "build1", "newbuild");
view.onJobRenamed(null, "build1", "newbuild");
//Delete
view.onProjectRenamed(null, "build1", null);
view.onJobRenamed(null, "build1", null);
}


@Test
public void testOnJobRenamedDelete() throws Exception {

FreeStyleProject p1 = jenkins.createFreeStyleProject("build1");

@WithoutJenkins
public void testOnJobRenamedDelete() {
List<DeliveryPipelineView.ComponentSpec> componentSpecs = new ArrayList<DeliveryPipelineView.ComponentSpec>();
componentSpecs.add(new DeliveryPipelineView.ComponentSpec("comp1", "build1"));
componentSpecs.add(new DeliveryPipelineView.ComponentSpec("comp2", "build2"));




DeliveryPipelineView view = new DeliveryPipelineView("Test");
view.setComponentSpecs(componentSpecs);

jenkins.getInstance().addView(view);

assertEquals(2, view.getComponentSpecs().size());

p1.delete();
view.onJobRenamed(null, "build1", null);

assertEquals(1, view.getComponentSpecs().size());

Expand All @@ -135,7 +122,6 @@ public void testSubmit() throws Exception {

@Test
@WithoutJenkins
@SuppressWarnings("all")
public void testDoCheckUpdateInterval() {
DeliveryPipelineView.DescriptorImpl d = new DeliveryPipelineView.DescriptorImpl();
assertEquals(FormValidation.Kind.ERROR, d.doCheckUpdateInterval("").kind);
Expand Down Expand Up @@ -383,7 +369,6 @@ public void testGetPipelines() throws Exception {

@Test
@WithoutJenkins
@SuppressWarnings("all")
public void testDoCheckName() {
DeliveryPipelineView.ComponentSpec.DescriptorImpl d = new DeliveryPipelineView.ComponentSpec.DescriptorImpl();
assertEquals(FormValidation.Kind.ERROR, d.doCheckName(null).kind);
Expand All @@ -396,7 +381,6 @@ public void testDoCheckName() {

@Test
@WithoutJenkins
@SuppressWarnings("all")
public void testDoCheckRegexpFirstJob() {
DeliveryPipelineView.RegExpSpec.DescriptorImpl d = new DeliveryPipelineView.RegExpSpec.DescriptorImpl();
assertEquals(FormValidation.Kind.OK, d.doCheckRegexp(null).kind);
Expand Down Expand Up @@ -533,11 +517,11 @@ public void testDoCreateItem() throws Exception {
testDoCreateItem("testDoCreateItem", "");

DeliveryPipelineView view = new DeliveryPipelineView("Delivery Pipeline");
jenkins.getInstance().addView(view);
jenkins.hudson.addView(view);

testDoCreateItem("testDoCreateItemAsTheDefaultViewFromTheViewUrl", "view/Delivery%20Pipeline/");

jenkins.getInstance().setPrimaryView(view);
jenkins.hudson.setPrimaryView(view);
testDoCreateItem("testDoCreateItemAsTheDefaultView", "");
}

Expand Down
40 changes: 0 additions & 40 deletions src/test/java/se/diabol/jenkins/pipeline/domain/EdgeTest.java

This file was deleted.

Expand Up @@ -266,9 +266,4 @@ public void testHashcodeEquals() {
assertNotEquals(trigger1.hashCode(), trigger3.hashCode());
}

@Test
public void testNullUser() {
assertEquals("anonymous", Trigger.getDisplayName(null));
}

}
Expand Up @@ -96,7 +96,6 @@ public void testGetTriggeredByWithCulprits() throws Exception {

@Test
@WithoutJenkins
@SuppressWarnings("all")
public void testEqualsHashCode() {
UserInfo userInfo1 = new UserInfo("name", null);
assertTrue(userInfo1.equals(userInfo1));
Expand All @@ -106,11 +105,9 @@ public void testEqualsHashCode() {
assertFalse(userInfo2.equals(null));
assertFalse(userInfo2.equals("name"));


UserInfo userInfo3 = new UserInfo("name1", "http://nowhere.com");
assertEquals(userInfo1.hashCode(), userInfo2.hashCode());
assertNotEquals(userInfo1.hashCode(), userInfo3.hashCode());
assertNotEquals(userInfo1, userInfo3);
}

}

0 comments on commit 18e2533

Please sign in to comment.