Skip to content

Commit

Permalink
Merge #2676
Browse files Browse the repository at this point in the history
2676: fix(protocol): change custom headers to Map<String,String> r=MiguelPires a=MiguelPires

closes #2656 


Co-authored-by: Miguel Pires <miguel.pires@camunda.com>
  • Loading branch information
zeebe-bors-heroku[bot] and Miguel Pires committed Jun 21, 2019
2 parents 1fd03da + 2d05e3b commit 05fe865
Show file tree
Hide file tree
Showing 15 changed files with 275 additions and 605 deletions.
Expand Up @@ -34,6 +34,8 @@ public class ExporterObjectMapper {

private static final TypeReference<Map<String, Object>> MAP_TYPE_REFERENCE =
new TypeReference<Map<String, Object>>() {};
private static final TypeReference<Map<String, Object>> STRING_MAP_TYPE_REFERENCE =
new TypeReference<Map<String, Object>>() {};

private final ObjectMapper msgpackObjectMapper;
private final ObjectMapper jsonObjectMapper;
Expand Down Expand Up @@ -105,4 +107,12 @@ public Map<String, Object> fromMsgpackAsMap(InputStream inputStream) {
throw new RuntimeException("Failed deserialize Msgpack JSON to map", e);
}
}

public Map<String, String> fromMsgpackAsStringMap(InputStream inputStream) {
try {
return msgpackObjectMapper.readValue(inputStream, STRING_MAP_TYPE_REFERENCE);
} catch (IOException e) {
throw new RuntimeException("Failed deserialize Msgpack JSON to map", e);
}
}
}
4 changes: 2 additions & 2 deletions clients/go/entities/job.go
Expand Up @@ -32,8 +32,8 @@ func (job *Job) GetVariablesAs(variablesType interface{}) error {
return json.Unmarshal([]byte(job.Variables), variablesType)
}

func (job *Job) GetCustomHeadersAsMap() (map[string]interface{}, error) {
var customHeadersMap map[string]interface{}
func (job *Job) GetCustomHeadersAsMap() (map[string]string, error) {
var customHeadersMap map[string]string
return customHeadersMap, job.GetCustomHeadersAs(&customHeadersMap)
}

Expand Down
8 changes: 6 additions & 2 deletions clients/go/entities/job_test.go
Expand Up @@ -31,6 +31,10 @@ var (
"foo": "bar",
"hello": "world",
}
expectedJsonAsMapVariables = map[string]interface{}{
"foo": "bar",
"hello": "world",
}
expectedJsonAsStruct = MyType{
Foo: "bar",
Hello: "world",
Expand All @@ -46,7 +50,7 @@ func TestJob_GetVariablesAsMap(t *testing.T) {
if err != nil {
t.Error("Failed to get variables as map", err)
}
if reflect.DeepEqual(variables, expectedJsonAsMap) {
if !reflect.DeepEqual(variables, expectedJsonAsMapVariables) {
t.Error("Failed to get variables as map, got", variables, "instead of", expectedJsonAsMap)
}
}
Expand All @@ -66,7 +70,7 @@ func TestJob_GetCustomHeadersAsMap(t *testing.T) {
if err != nil {
t.Error("Failed to get custom headers as map", err)
}
if reflect.DeepEqual(customHeaders, expectedJsonAsMap) {
if !reflect.DeepEqual(customHeaders, expectedJsonAsMap) {
t.Error("Failed to get custom headers as map, got", customHeaders, "instead of", expectedJsonAsMap)
}
}
Expand Down
277 changes: 120 additions & 157 deletions clients/go/mock_pb/mock_gateway.go

Large diffs are not rendered by default.

0 comments on commit 05fe865

Please sign in to comment.