Skip to content

Commit 08cd6b6

Browse files
KrispauIdependabot[bot]melisolmez
authored
[ISSUE apache#4990] Add unit test for HttpConvertsUtils.java (apache#5110)
* add unit test for HttpConvertsUtils.java * fix package error * Bump com.gradle.develocity from 3.17.5 to 3.18.1 (apache#5121) Bumps com.gradle.develocity from 3.17.5 to 3.18.1. --- updated-dependencies: - dependency-name: com.gradle.develocity dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump software.amazon.awssdk:s3 from 2.27.17 to 2.28.12 (apache#5120) Bumps software.amazon.awssdk:s3 from 2.27.17 to 2.28.12. --- updated-dependencies: - dependency-name: software.amazon.awssdk:s3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * [ISSUE apache#4540] Add unit test for ThreadUtils (apache#5111) * Bump com.rabbitmq:amqp-client from 5.21.0 to 5.22.0 (apache#5119) Bumps [com.rabbitmq:amqp-client](https://github.com/rabbitmq/rabbitmq-java-client) from 5.21.0 to 5.22.0. - [Release notes](https://github.com/rabbitmq/rabbitmq-java-client/releases) - [Commits](rabbitmq/rabbitmq-java-client@v5.21.0...v5.22.0) --- updated-dependencies: - dependency-name: com.rabbitmq:amqp-client dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix CI errors --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Melis Ölmez <[email protected]>
1 parent fc3a5f3 commit 08cd6b6

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.common.stubs;
19+
20+
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
21+
import org.apache.eventmesh.common.protocol.http.header.Header;
22+
import org.apache.eventmesh.common.utils.HttpConvertsUtils;
23+
24+
import java.util.Map;
25+
26+
public class HeaderStub extends Header {
27+
28+
public String code;
29+
public String eventmeshenv;
30+
31+
@Override
32+
public Map<String, Object> toMap() {
33+
return new HttpConvertsUtils().httpMapConverts(this, new ProtocolKey(), new ProtocolKey.EventMeshInstanceKey());
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.common.utils;
19+
20+
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
21+
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey.EventMeshInstanceKey;
22+
import org.apache.eventmesh.common.protocol.http.header.Header;
23+
import org.apache.eventmesh.common.stubs.HeaderStub;
24+
25+
import java.util.HashMap;
26+
import java.util.Map;
27+
28+
import org.junit.jupiter.api.Assertions;
29+
import org.junit.jupiter.api.Test;
30+
31+
class HttpConvertsUtilsTest {
32+
33+
private final HeaderStub headerStub = new HeaderStub();
34+
private final ProtocolKey mockedProtocolKey = new ProtocolKey();
35+
private final EventMeshInstanceKey mockedEventMeshProtocolKey = new EventMeshInstanceKey();
36+
37+
@Test
38+
void httpMapConverts() {
39+
Map<String, Object> httpMapConverts = new HttpConvertsUtils().httpMapConverts(headerStub, mockedProtocolKey);
40+
Assertions.assertEquals(httpMapConverts.get(headerStub.code), headerStub.code);
41+
}
42+
43+
@Test
44+
void testHttpMapConverts() {
45+
Map<String, Object> httpMapConverts = new HttpConvertsUtils().httpMapConverts(headerStub, mockedProtocolKey, mockedEventMeshProtocolKey);
46+
Assertions.assertEquals(httpMapConverts.get(headerStub.code), headerStub.code);
47+
Assertions.assertEquals(httpMapConverts.get(headerStub.eventmeshenv), headerStub.eventmeshenv);
48+
}
49+
50+
@Test
51+
void httpHeaderConverts() {
52+
HashMap<String, Object> headerParams = new HashMap<>();
53+
String code = "test";
54+
headerParams.put("code", code);
55+
Header header = new HttpConvertsUtils().httpHeaderConverts(headerStub, headerParams);
56+
Assertions.assertEquals(code, header.toMap().get("code"));
57+
}
58+
59+
@Test
60+
void testHttpHeaderConverts() {
61+
HashMap<String, Object> headerParams = new HashMap<>();
62+
String env = "test";
63+
headerParams.put("eventmeshenv", env);
64+
Header header = new HttpConvertsUtils().httpHeaderConverts(headerStub, headerParams, mockedEventMeshProtocolKey);
65+
Assertions.assertEquals(env, header.toMap().get("eventmeshenv"));
66+
}
67+
}

0 commit comments

Comments
 (0)