Created
September 11, 2020 09:24
-
-
Save djkeh/f430b1e0254c7d546ec662d3d70da102 to your computer and use it in GitHub Desktop.
Test case which shows a bug on AbstractSerializableParameter in io.swagger:swagger-models:1.5.20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.bootdemo; | |
import io.swagger.models.parameters.AbstractSerializableParameter; | |
import io.swagger.models.properties.BaseIntegerProperty; | |
import org.junit.jupiter.api.AfterEach; | |
import org.junit.jupiter.api.BeforeEach; | |
import org.junit.jupiter.api.Test; | |
import java.io.ByteArrayOutputStream; | |
import java.io.PrintStream; | |
import static org.assertj.core.api.Assertions.*; | |
/** | |
* @see io.swagger.annotations.ApiImplicitParam @ApiImplicitParam | |
*/ | |
public class LogicTest { | |
private AbstractSerializableParameter<AnyParameter> parameter; | |
private static class AnyParameter extends AbstractSerializableParameter<AnyParameter> {} // just a dummy | |
private final ByteArrayOutputStream out = new ByteArrayOutputStream(); | |
@BeforeEach | |
void beforeEach() { | |
parameter = new AbstractSerializableParameter<>() {}; | |
System.setOut(new PrintStream(out)); | |
} | |
@AfterEach | |
void afterEach() { | |
System.setOut(System.out); | |
} | |
@Test | |
void givenNull_whenGettingExample_thenShowNoWarningLog() { | |
// Given | |
parameter.setExample(null); | |
parameter.setType(BaseIntegerProperty.TYPE); | |
// When | |
parameter.getExample(); | |
// Then | |
assertThat(out.toString()).isEqualTo(""); | |
} | |
/** | |
* Test that fails | |
*/ | |
@Test | |
void givenEmptyString_whenGettingExample_thenShowNoWarningLog() { | |
// Given | |
parameter.setExample(""); | |
parameter.setType(BaseIntegerProperty.TYPE); | |
// When | |
parameter.getExample(); | |
// Then | |
assertThat(out.toString()).isEqualTo(""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This bug has been fixed already in the later verion
1.5.21
ofswagger-models
. But the latest version ofspringfox-boot-starter 3.0.0
still has this dependency. I raised an issue for solving this problem at: