Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisLainez committed Apr 26, 2024
1 parent d8b2f1b commit eece524
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
* specific language governing permissions and limitations under the License.
*/
package com.netflix.conductor.client.http
import org.glassfish.jersey.client.ClientResponse

import com.netflix.conductor.client.exception.ConductorClientException
import com.netflix.conductor.common.metadata.workflow.WorkflowDef

import jakarta.ws.rs.core.GenericType
import spock.lang.Subject

class MetadataClientSpec extends ClientSpecification {
Expand Down Expand Up @@ -82,13 +82,13 @@ class MetadataClientSpec extends ClientSpecification {
given:
List<WorkflowDef> result = new ArrayList<WorkflowDef>()
URI uri = createURI("metadata/workflow/latest-versions")
GenericType<List<WorkflowDef>> workflowDefList =
new GenericType<List<WorkflowDef>>() {};

when:
metadataClient.getAllWorkflowsWithLatestVersions()

then:
1 * requestHandler.get(uri) >> Mock(ClientResponse.class) {
getEntity(_) >> result
}
1 * requestHandler.getWithGenericType(uri, workflowDefList) >> result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
*/
package com.netflix.conductor.client.http

import org.glassfish.jersey.client.ClientResponse

import com.netflix.conductor.common.metadata.tasks.Task
import com.netflix.conductor.common.run.SearchResult
import com.netflix.conductor.common.run.TaskSummary

import jakarta.ws.rs.core.GenericType
import spock.lang.Subject

class TaskClientSpec extends ClientSpecification {
Expand All @@ -36,16 +35,15 @@ class TaskClientSpec extends ClientSpecification {
SearchResult<TaskSummary> result = new SearchResult<>()
result.totalHits = 1
result.results = [new TaskSummary()]

GenericType<SearchResult<TaskSummary>> searchResultTaskSummary =
new GenericType<SearchResult<TaskSummary>>() {}
URI uri = createURI("tasks/search?query=$query")

when:
SearchResult<TaskSummary> searchResult = taskClient.search(query)

then:
1 * requestHandler.get(uri) >> Mock(ClientResponse.class) {
readEntity(_) >> result
}
1 * requestHandler.getWithGenericType(uri, searchResultTaskSummary) >> result

searchResult.totalHits == result.totalHits
searchResult.results && searchResult.results.size() == 1
Expand All @@ -58,16 +56,16 @@ class TaskClientSpec extends ClientSpecification {
SearchResult<Task> result = new SearchResult<>()
result.totalHits = 1
result.results = [new Task()]
GenericType<SearchResult<Task>> searchResultTask =
new GenericType<SearchResult<Task>>() {}

URI uri = createURI("tasks/search-v2?query=$query")

when:
SearchResult<Task> searchResult = taskClient.searchV2('my_complex_query')

then:
1 * requestHandler.get(uri) >> Mock(ClientResponse.class) {
readEntity(_) >> result
}
1 * requestHandler.getWithGenericType(uri, searchResultTask) >> result

searchResult.totalHits == result.totalHits
searchResult.results && searchResult.results.size() == 1
Expand All @@ -84,16 +82,16 @@ class TaskClientSpec extends ClientSpecification {
SearchResult<TaskSummary> result = new SearchResult<>()
result.totalHits = 1
result.results = [new TaskSummary()]
GenericType<SearchResult<TaskSummary>> searchResultTaskSummary =
new GenericType<SearchResult<TaskSummary>>() {}

URI uri = createURI("tasks/search?start=$start&size=$size&sort=$sort&freeText=$freeText&query=$query")

when:
SearchResult<TaskSummary> searchResult = taskClient.search(start, size, sort, freeText, query)

then:
1 * requestHandler.get(uri) >> Mock(ClientResponse.class) {
readEntity(_) >> result
}
1 * requestHandler.getWithGenericType(uri, searchResultTaskSummary) >> result

searchResult.totalHits == result.totalHits
searchResult.results && searchResult.results.size() == 1
Expand All @@ -110,16 +108,16 @@ class TaskClientSpec extends ClientSpecification {
SearchResult<Task> result = new SearchResult<>()
result.totalHits = 1
result.results = [new Task()]
GenericType<SearchResult<Task>> searchResultTask =
new GenericType<SearchResult<Task>>() {}

URI uri = createURI("tasks/search-v2?start=$start&size=$size&sort=$sort&freeText=$freeText&query=$query")

when:
SearchResult<Task> searchResult = taskClient.searchV2(start, size, sort, freeText, query)

then:
1 * requestHandler.get(uri) >> Mock(ClientResponse.class) {
readEntity(_) >> result
}
1 * requestHandler.getWithGenericType(uri, searchResultTask) >> result

searchResult.totalHits == result.totalHits
searchResult.results && searchResult.results.size() == 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
*/
package com.netflix.conductor.client.http

import org.glassfish.jersey.client.ClientResponse

import com.netflix.conductor.common.metadata.workflow.WorkflowDef
import com.netflix.conductor.common.run.SearchResult
import com.netflix.conductor.common.run.Workflow
import com.netflix.conductor.common.run.WorkflowSummary

import jakarta.ws.rs.core.GenericType
import spock.lang.Subject

class WorkflowClientSpec extends ClientSpecification {
Expand All @@ -37,16 +36,15 @@ class WorkflowClientSpec extends ClientSpecification {
SearchResult<WorkflowSummary> result = new SearchResult<>()
result.totalHits = 1
result.results = [new WorkflowSummary()]

GenericType<SearchResult<WorkflowSummary>> searchResultWorkflowSummary =
new GenericType<SearchResult<WorkflowSummary>>() {}
URI uri = createURI("workflow/search?query=$query")

when:
SearchResult<WorkflowSummary> searchResult = workflowClient.search(query)

then:
1 * requestHandler.get(uri) >> Mock(ClientResponse.class) {
readEntity(_) >> result
}
1 * requestHandler.getWithGenericType(uri, searchResultWorkflowSummary) >> result

searchResult.totalHits == result.totalHits
searchResult.results && searchResult.results.size() == 1
Expand All @@ -58,17 +56,16 @@ class WorkflowClientSpec extends ClientSpecification {
String query = 'my_complex_query'
SearchResult<Workflow> result = new SearchResult<>()
result.totalHits = 1
result.results = [new Workflow(workflowDefinition: new WorkflowDef(), createTime: System.currentTimeMillis() )]

result.results = [new Workflow(workflowDefinition: new WorkflowDef(), createTime: System.currentTimeMillis())]
GenericType<SearchResult<Workflow>> searchResultWorkflow =
new GenericType<SearchResult<Workflow>>() {}
URI uri = createURI("workflow/search-v2?query=$query")

when:
SearchResult<Workflow> searchResult = workflowClient.searchV2('my_complex_query')

then:
1 * requestHandler.get(uri) >> Mock(ClientResponse.class) {
readEntity(_) >> result
}
1 * requestHandler.getWithGenericType(uri, searchResultWorkflow) >> result

searchResult.totalHits == result.totalHits
searchResult.results && searchResult.results.size() == 1
Expand All @@ -85,16 +82,15 @@ class WorkflowClientSpec extends ClientSpecification {
SearchResult<WorkflowSummary> result = new SearchResult<>()
result.totalHits = 1
result.results = [new WorkflowSummary()]

GenericType<SearchResult<WorkflowSummary>> searchResultWorkflowSummary =
new GenericType<SearchResult<WorkflowSummary>>() {}
URI uri = createURI("workflow/search?start=$start&size=$size&sort=$sort&freeText=$freeText&query=$query")

when:
SearchResult<WorkflowSummary> searchResult = workflowClient.search(start, size, sort, freeText, query)

then:
1 * requestHandler.get(uri) >> Mock(ClientResponse.class) {
readEntity(_) >> result
}
1 * requestHandler.getWithGenericType(uri, searchResultWorkflowSummary) >> result

searchResult.totalHits == result.totalHits
searchResult.results && searchResult.results.size() == 1
Expand All @@ -110,17 +106,16 @@ class WorkflowClientSpec extends ClientSpecification {
String freeText = 'text'
SearchResult<Workflow> result = new SearchResult<>()
result.totalHits = 1
result.results = [new Workflow(workflowDefinition: new WorkflowDef(), createTime: System.currentTimeMillis() )]

result.results = [new Workflow(workflowDefinition: new WorkflowDef(), createTime: System.currentTimeMillis())]
GenericType<SearchResult<Workflow>> searchResultWorkflow =
new GenericType<SearchResult<Workflow>>() {}
URI uri = createURI("workflow/search-v2?start=$start&size=$size&sort=$sort&freeText=$freeText&query=$query")

when:
SearchResult<Workflow> searchResult = workflowClient.searchV2(start, size, sort, freeText, query)

then:
1 * requestHandler.get(uri) >> Mock(ClientResponse.class) {
readEntity(_) >> result
}
1 * requestHandler.getWithGenericType(uri,searchResultWorkflow) >> result

searchResult.totalHits == result.totalHits
searchResult.results && searchResult.results.size() == 1
Expand Down

0 comments on commit eece524

Please sign in to comment.