-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a bunch of tests around DeploymentCompleteCheckJob
- Loading branch information
1 parent
e33ceee
commit 312a6eb
Showing
16 changed files
with
517 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 11 additions & 83 deletions
94
.../java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/DeploymentsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,11 @@ | ||
/* | ||
* Copyright 2000-2013 JetBrains s.r.o. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.mjrichardson.teamCity.buildTriggers.DeploymentComplete; | ||
|
||
import com.intellij.openapi.diagnostic.Logger; | ||
import com.mjrichardson.teamCity.buildTriggers.*; | ||
|
||
import java.security.KeyManagementException; | ||
import java.security.KeyStoreException; | ||
import java.security.NoSuchAlgorithmException; | ||
|
||
//todo needs tests | ||
public final class DeploymentsProvider { | ||
|
||
private final HttpContentProvider contentProvider; | ||
private final Logger LOG; | ||
|
||
public DeploymentsProvider(String octopusUrl, String apiKey, Integer connectionTimeout, Logger log) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException { | ||
this(new HttpContentProviderImpl(log, octopusUrl, apiKey, connectionTimeout), log); | ||
} | ||
|
||
public DeploymentsProvider(HttpContentProvider contentProvider, Logger log) | ||
{ | ||
this.contentProvider = contentProvider; | ||
this.LOG = log; | ||
} | ||
|
||
public Deployments getDeployments(String projectId, Deployments oldDeployments) throws DeploymentsProviderException, ProjectNotFoundException, InvalidOctopusApiKeyException, InvalidOctopusUrlException { | ||
//get {octopusurl}/api | ||
//parse out project url | ||
//parse out progression url | ||
//call project url | ||
//parse id for project | ||
//call progression url for project id | ||
//return NewDeploymentStatus(responseBody); | ||
|
||
try { | ||
LOG.debug("DeploymentCompleteBuildTrigger: Getting deployments from " + contentProvider.getUrl() + " for project id '" + projectId + "'"); | ||
|
||
final String apiResponse = contentProvider.getContent("/api"); | ||
final ApiRootResponse apiRootResponse = new ApiRootResponse(apiResponse); | ||
|
||
final String progressionResponse = contentProvider.getContent(apiRootResponse.progressionApiLink + "/" + projectId); | ||
final ApiProgressionResponse apiProgressionResponse = new ApiProgressionResponse(progressionResponse); | ||
|
||
if (apiProgressionResponse.haveCompleteInformation) | ||
return apiProgressionResponse.deployments; | ||
|
||
final ApiDeploymentsResponse apiDeploymentsResponse = new ApiDeploymentsResponse( | ||
contentProvider, apiRootResponse.deploymentsApiLink, projectId, | ||
oldDeployments, apiProgressionResponse.deployments); | ||
|
||
return apiDeploymentsResponse.deployments; | ||
} | ||
catch (InvalidOctopusApiKeyException e) { | ||
throw e; | ||
} | ||
catch (InvalidOctopusUrlException e) { | ||
throw e; | ||
} | ||
catch (ProjectNotFoundException e) { | ||
throw e; | ||
} | ||
catch (Throwable e) { | ||
//todo: improve error message here | ||
throw new DeploymentsProviderException("URL " + contentProvider.getUrl() + ": " + e, e); | ||
} | ||
} | ||
} | ||
package com.mjrichardson.teamCity.buildTriggers.DeploymentComplete; | ||
|
||
import com.mjrichardson.teamCity.buildTriggers.InvalidOctopusApiKeyException; | ||
import com.mjrichardson.teamCity.buildTriggers.InvalidOctopusUrlException; | ||
import com.mjrichardson.teamCity.buildTriggers.ProjectNotFoundException; | ||
|
||
import java.text.ParseException; | ||
|
||
public interface DeploymentsProvider { | ||
Deployments getDeployments(String octopusProject, Deployments oldDeployments) throws DeploymentsProviderException, ProjectNotFoundException, InvalidOctopusApiKeyException, InvalidOctopusUrlException, ParseException; | ||
} |
12 changes: 12 additions & 0 deletions
12
...om/mjrichardson/teamCity/buildTriggers/DeploymentComplete/DeploymentsProviderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.mjrichardson.teamCity.buildTriggers.DeploymentComplete; | ||
|
||
import java.security.KeyManagementException; | ||
import java.security.KeyStoreException; | ||
import java.security.NoSuchAlgorithmException; | ||
|
||
|
||
public class DeploymentsProviderFactory { | ||
public DeploymentsProvider getProvider(String octopusUrl, String octopusApiKey, Integer connectionTimeout) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException { | ||
return new DeploymentsProviderImpl(octopusUrl, octopusApiKey, connectionTimeout); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...a/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/DeploymentsProviderImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2000-2013 JetBrains s.r.o. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.mjrichardson.teamCity.buildTriggers.DeploymentComplete; | ||
|
||
import com.intellij.openapi.diagnostic.Logger; | ||
import com.mjrichardson.teamCity.buildTriggers.*; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.security.KeyManagementException; | ||
import java.security.KeyStoreException; | ||
import java.security.NoSuchAlgorithmException; | ||
|
||
//todo needs tests | ||
public class DeploymentsProviderImpl implements DeploymentsProvider { | ||
|
||
private final HttpContentProvider contentProvider; | ||
@NotNull | ||
private static final Logger LOG = Logger.getInstance(DeploymentsProviderImpl.class.getName()); | ||
|
||
public DeploymentsProviderImpl(String octopusUrl, String apiKey, Integer connectionTimeout) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException { | ||
this(new HttpContentProviderImpl(octopusUrl, apiKey, connectionTimeout)); | ||
} | ||
|
||
public DeploymentsProviderImpl(HttpContentProvider contentProvider) | ||
{ | ||
this.contentProvider = contentProvider; | ||
} | ||
|
||
public Deployments getDeployments(String projectId, Deployments oldDeployments) throws DeploymentsProviderException, ProjectNotFoundException, InvalidOctopusApiKeyException, InvalidOctopusUrlException { | ||
//get {octopusurl}/api | ||
//parse out project url | ||
//parse out progression url | ||
//call project url | ||
//parse id for project | ||
//call progression url for project id | ||
//return NewDeploymentStatus(responseBody); | ||
|
||
try { | ||
LOG.debug("DeploymentCompleteBuildTrigger: Getting deployments from " + contentProvider.getUrl() + " for project id '" + projectId + "'"); | ||
|
||
final String apiResponse = contentProvider.getContent("/api"); | ||
final ApiRootResponse apiRootResponse = new ApiRootResponse(apiResponse); | ||
|
||
final String progressionResponse = contentProvider.getContent(apiRootResponse.progressionApiLink + "/" + projectId); | ||
final ApiProgressionResponse apiProgressionResponse = new ApiProgressionResponse(progressionResponse); | ||
|
||
if (apiProgressionResponse.haveCompleteInformation) | ||
return apiProgressionResponse.deployments; | ||
|
||
final ApiDeploymentsResponse apiDeploymentsResponse = new ApiDeploymentsResponse( | ||
contentProvider, apiRootResponse.deploymentsApiLink, projectId, | ||
oldDeployments, apiProgressionResponse.deployments); | ||
|
||
return apiDeploymentsResponse.deployments; | ||
} | ||
catch (InvalidOctopusApiKeyException e) { | ||
throw e; | ||
} | ||
catch (InvalidOctopusUrlException e) { | ||
throw e; | ||
} | ||
catch (ProjectNotFoundException e) { | ||
throw e; | ||
} | ||
catch (Throwable e) { | ||
//todo: improve error message here | ||
throw new DeploymentsProviderException("URL " + contentProvider.getUrl() + ": " + e, e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.