-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Hello, When using the current solution, I noticed one, in my opinion, not very successful solution, which led to a problem after deploying the component. The org.mockserver.model.Headers class under the hood uses Google Multimap, inside which the header values are collected in a Set, which leads to the fact that the header
"custom_header": ["custom_val", "custom_val"], is converted to "custom_header": ["custom_val"].
And all this, in fact, can lead to a discrepancy with what will actually be on the prom. As if it would be more correct to collect the header values not in a Set, but in some List implementation.
MockServer version
all
To Reproduce
Steps to reproduce the issue:
import org.junit.jupiter.api.Test;
import org.mockserver.model.Header;
import org.mockserver.model.Headers;
import org.mockserver.model.NottableString;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ExampleTest {
@Test
void test() {
final Header header = new Header("header", "val", "val");
final Headers headers = Headers.headers(header);
final List<String> actualValues = headers.getValues("header");
assertEquals(List.of("val", "val"), actualValues); //Expected
assertEquals(List.of("val"), actualValues); //Actual
//OR
assertEquals(header.getValues().stream().map(NottableString::getValue).toList(), actualValues); //Expected
assertEquals(header.getValues().stream().map(NottableString::getValue).collect(Collectors.toSet()), new HashSet<>(actualValues)); //Actual
}
}
Metadata
Metadata
Assignees
Labels
No labels