Simplified the DeploymentDAOSpec tests

Updated as per the code review comments

References #169
This commit is contained in:
Mahesh V Kelkar 2015-04-29 12:05:10 -04:00
parent 3954d8c1b9
commit 3c1260ac90
3 changed files with 9 additions and 13 deletions

View File

@ -62,8 +62,8 @@ class DeploymentDAO extends AbstractDAO<Deployment> {
/**
* Find deployments for an environment
*
* @param environmentIdent ident of the Environment
* @return deployments
* @param envIdent identity of the Environment
* @return deployments list of Deployments
*/
List<Deployment> getByEnvironmentIdent(String envIdent,
int pageNumber, int perPageSize) {

View File

@ -67,10 +67,10 @@ public class EnvironmentResource {
/**
* Returns the deployments using artifact id
* Returns the deployments using environment identitiy
*
* @param artifactId id of the artifact
* @return deployments
* @param environmentIdent identity of the Environemnt
* @return deployments list of Deployments
*/
@GET
@Path("/{name}/deployments")
@ -83,10 +83,10 @@ public class EnvironmentResource {
deploydb.ModelPageSizeParam perPageSize) {
List<Deployment> deploymentList = this.workFlow.deploymentDAO
.getByEnvironmentIdent(environmentIdent, pageNumber.get(), perPageSize.get())
if (deploymentList == null || deploymentList.isEmpty()) {
throw new WebApplicationException(Response.Status.NOT_FOUND)
if (deploymentList) {
return deploymentList
}
return deploymentList
throw new WebApplicationException(Response.Status.NOT_FOUND)
}
}

View File

@ -45,7 +45,7 @@ class DeploymentDAOSpec extends Specification {
dao.getByArtifactId(1).isEmpty()
}
def "getByEnvironmentIdent() should return null if there are no deployments"() {
def "getByEnvironmentIdent() should return empty list if there are no deployments"() {
when:
List<Deployment> deploymentsByEnv
integAppHelper.withSession {
@ -72,19 +72,15 @@ class DeploymentDAOSpec extends Specification {
when:
List<Deployment> deploymentsByEnv
List<Deployment> allDeployments
List<Deployment> deploymentsByUnknownEnv
integAppHelper.withSession {
deploymentsByEnv = integAppHelper.runner.getApplication().workFlow.deploymentDAO
.getByEnvironmentIdent("basicEnv", 0, 20)
allDeployments = integAppHelper.runner.getApplication().workFlow.deploymentDAO
.getByPage(0, 20)
deploymentsByUnknownEnv = integAppHelper.runner.getApplication().workFlow.deploymentDAO
.getByEnvironmentIdent("integ", 0, 20)
}
then:
deploymentsByEnv.size() == 1
deploymentsByEnv == allDeployments
deploymentsByUnknownEnv.isEmpty()
}
}