Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameters and global parameters to Definitions #399

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/java/com/rabbitmq/http/client/domain/Definitions.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Definitions {
Expand All @@ -36,6 +37,11 @@ public class Definitions {
@JsonProperty("topic_permissions")
private List<TopicPermissions> topicPermissions = new ArrayList<>();

private List<RuntimeParameter<Object>> parameters = new ArrayList<>();

@JsonProperty("global_parameters")
private List<RuntimeParameter<Object>> globalParameters = new ArrayList<>();

private List<QueueInfo> queues = new ArrayList<QueueInfo>();

private List<ExchangeInfo> exchanges = new ArrayList<ExchangeInfo>();
Expand Down Expand Up @@ -106,6 +112,22 @@ public List<TopicPermissions> getTopicPermissions() {
return topicPermissions;
}

public void setParameters(List<RuntimeParameter<Object>> parameters) {
this.parameters = parameters;
}

public List<RuntimeParameter<Object>> getParameters() {
return parameters;
}

public void setGlobalParameters(List<RuntimeParameter<Object>> globalParameters) {
this.globalParameters = globalParameters;
}

public List<RuntimeParameter<Object>> getGlobalParameters() {
return globalParameters;
}

@Override
public String toString() {
return "Definitions{" +
Expand Down
36 changes: 36 additions & 0 deletions src/test/groovy/com/rabbitmq/http/client/ClientSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,42 @@ class ClientSpec extends Specification {

}

def "GET /api/definitions (parameters)"() {
given: "a (shovel) parameter defined"
ShovelDetails value = new ShovelDetails("amqp://localhost:5672/vh1", "amqp://localhost:5672/vh2", 30, true, null)
value.setSourceQueue("queue1")
value.setDestinationExchange("exchange1")
value.setSourcePrefetchCount(50L)
value.setSourceDeleteAfter("never")
value.setDestinationAddTimestampHeader(true)
client.declareShovel("/", new ShovelInfo("shovel1", value))
when: "client gets the parameters and global parameters"
Definitions d = client.getDefinitions()
List<RuntimeParameter<Object>> parameters = d.getParameters()
List<RuntimeParameter<Object>> globalParameters = d.getGlobalParameters()

then: "a parameter with a JSON document value and a parameter with a string value are deserialized"
!parameters.isEmpty()
RuntimeParameter<Object> parameter = parameters.find { (it.name == "shovel1") } as RuntimeParameter<Object>
parameter != null
parameter.name == "shovel1"
parameter.vhost == "/"
parameter.component == "shovel"
parameter.value instanceof Map
parameter.value["src-queue"] == "queue1"
parameter.value["dest-exchange"] == "exchange1"

!globalParameters.isEmpty()
RuntimeParameter<Object> globalParameter = globalParameters.find { (it.name == "internal_cluster_id") } as RuntimeParameter<Object>
globalParameter != null
globalParameter.name == "internal_cluster_id"
globalParameter.value instanceof String

cleanup:
client.deleteShovel("/","shovel1")
client.deleteQueue("/", "queue1")

}

def "GET /api/parameters/shovel"() {
given: "a shovel defined"
Expand Down