-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Nosto/improvement/detectCamelCasePropertie…
…sWhenSnakeCaseConfigured Detect when camel case properties are used for a class that's configured to use snake case
- Loading branch information
Showing
8 changed files
with
234 additions
and
50 deletions.
There are no files selected for viewing
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
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
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
57 changes: 57 additions & 0 deletions
57
beanie-core/src/test/java/com/nosto/beanie/InvalidSnakeCasePropertyNamingStrategyTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2021 Nosto Solutions Ltd All Rights Reserved. | ||
* | ||
* This software is the confidential and proprietary information of | ||
* Nosto Solutions Ltd ("Confidential Information"). You shall not | ||
* disclose such Confidential Information and shall use it only in | ||
* accordance with the terms of the agreement you entered into with | ||
* Nosto Solutions Ltd. | ||
*/ | ||
|
||
package com.nosto.beanie; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.PropertyNamingStrategy; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
import org.junit.Test; | ||
|
||
public class InvalidSnakeCasePropertyNamingStrategyTest extends AbstractJacksonBeanTest<InvalidSnakeCasePropertyNamingStrategyTest.TestBean, InvalidSnakeCasePropertyNamingStrategyTest.TestBean> { | ||
public InvalidSnakeCasePropertyNamingStrategyTest() { | ||
super(TestBean.class); | ||
} | ||
|
||
@Test(expected = AssertionError.class) | ||
@Override | ||
public void namingStrategy() { | ||
super.namingStrategy(); | ||
} | ||
|
||
@Override | ||
protected BeanieProvider getBeanieProvider() { | ||
return new DefaultBeanieProvider(); | ||
} | ||
|
||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | ||
public static class TestBean extends AbstractTestBean { | ||
|
||
private final String propertyA; | ||
private final String propertyB; | ||
|
||
@JsonCreator | ||
public TestBean(@JsonProperty("propertyA") String propertyA, @JsonProperty("propertyB") String propertyB) { | ||
this.propertyA = propertyA; | ||
this.propertyB = propertyB; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public String getPropertyA() { | ||
return propertyA; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public String getPropertyB() { | ||
return propertyB; | ||
} | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
beanie-core/src/test/java/com/nosto/beanie/ValidCamelCasePropertyNamingStrategyTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2021 Nosto Solutions Ltd All Rights Reserved. | ||
* | ||
* This software is the confidential and proprietary information of | ||
* Nosto Solutions Ltd ("Confidential Information"). You shall not | ||
* disclose such Confidential Information and shall use it only in | ||
* accordance with the terms of the agreement you entered into with | ||
* Nosto Solutions Ltd. | ||
*/ | ||
|
||
package com.nosto.beanie; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class ValidCamelCasePropertyNamingStrategyTest extends AbstractJacksonBeanTest<ValidCamelCasePropertyNamingStrategyTest.TestBean, ValidCamelCasePropertyNamingStrategyTest.TestBean> { | ||
public ValidCamelCasePropertyNamingStrategyTest() { | ||
super(TestBean.class); | ||
} | ||
|
||
@Override | ||
protected BeanieProvider getBeanieProvider() { | ||
return new DefaultBeanieProvider(); | ||
} | ||
|
||
public static class TestBean extends AbstractTestBean { | ||
|
||
private final String propertyA; | ||
private final String propertyB; | ||
|
||
@JsonCreator | ||
public TestBean(@JsonProperty("propertyA") String propertyA, @JsonProperty("propertyB") String propertyB) { | ||
this.propertyA = propertyA; | ||
this.propertyB = propertyB; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public String getPropertyA() { | ||
return propertyA; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public String getPropertyB() { | ||
return propertyB; | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
beanie-core/src/test/java/com/nosto/beanie/ValidSnakeCasePropertyNamingStrategyTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2021 Nosto Solutions Ltd All Rights Reserved. | ||
* | ||
* This software is the confidential and proprietary information of | ||
* Nosto Solutions Ltd ("Confidential Information"). You shall not | ||
* disclose such Confidential Information and shall use it only in | ||
* accordance with the terms of the agreement you entered into with | ||
* Nosto Solutions Ltd. | ||
*/ | ||
|
||
package com.nosto.beanie; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.PropertyNamingStrategy; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
||
public class ValidSnakeCasePropertyNamingStrategyTest extends AbstractJacksonBeanTest<ValidSnakeCasePropertyNamingStrategyTest.TestBean, ValidSnakeCasePropertyNamingStrategyTest.TestBean> { | ||
public ValidSnakeCasePropertyNamingStrategyTest() { | ||
super(TestBean.class); | ||
} | ||
|
||
@Override | ||
protected BeanieProvider getBeanieProvider() { | ||
return new DefaultBeanieProvider(); | ||
} | ||
|
||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | ||
public static class TestBean extends AbstractTestBean { | ||
|
||
private final String propertyA; | ||
private final String propertyB; | ||
|
||
@JsonCreator | ||
public TestBean(@JsonProperty("property_a") String propertyA, @JsonProperty("property_b") String propertyB) { | ||
this.propertyA = propertyA; | ||
this.propertyB = propertyB; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public String getPropertyA() { | ||
return propertyA; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public String getPropertyB() { | ||
return propertyB; | ||
} | ||
} | ||
} |
Oops, something went wrong.