Merge branch 'master' into thombergs-patch-6
This commit is contained in:
commit
1a58d62dcf
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class CayenneAdvancedOperationIntegrationTest {
|
||||
public class CayenneAdvancedOperationLiveTest {
|
||||
private static ObjectContext context = null;
|
||||
|
||||
@BeforeClass
|
|
@ -16,7 +16,7 @@ import static junit.framework.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNull;
|
||||
|
||||
|
||||
public class CayenneOperationIntegrationTest {
|
||||
public class CayenneOperationLiveTest {
|
||||
private static ObjectContext context = null;
|
||||
|
||||
@BeforeClass
|
|
@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class AzureApplicationTests {
|
||||
public class AzureApplicationIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
|
@ -9,7 +9,7 @@ import java.util.Optional;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
public class MethodParamNameTest {
|
||||
public class MethodParamNameUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenGetConstructorParams_thenOk()
|
|
@ -77,6 +77,6 @@ public class FilesManualTest {
|
|||
bw.newLine();
|
||||
bw.close();
|
||||
|
||||
assertThat(StreamUtils.getStringFromInputStream(new FileInputStream(fileName))).isEqualTo("UK\r\n" + "US\r\n" + "Germany\r\n" + "Spain\n");
|
||||
assertThat(StreamUtils.getStringFromInputStream(new FileInputStream(fileName))).isEqualTo("UK\r\n" + "US\r\n" + "Germany\r\n" + "Spain\r\n");
|
||||
}
|
||||
}
|
|
@ -106,7 +106,7 @@ public class JavaReadFromFileUnitTest {
|
|||
|
||||
@Test
|
||||
public void whenReadUTFEncodedFile_thenCorrect() throws IOException {
|
||||
final String expected_value = "é<EFBFBD>’空";
|
||||
final String expected_value = "青空";
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.in"), "UTF-8"));
|
||||
final String currentLine = reader.readLine();
|
||||
reader.close();
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.io.PrintStream;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
public class JaggedArrayTest {
|
||||
public class JaggedArrayUnitTest {
|
||||
|
||||
private JaggedArray obj = new JaggedArray();
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.baeldung.enums
|
||||
|
||||
enum class CardType(val color: String) : ICardLimit {
|
||||
SILVER("gray") {
|
||||
override fun getCreditLimit(): Int {
|
||||
return 100000
|
||||
}
|
||||
|
||||
override fun calculateCashbackPercent(): Float {
|
||||
return 0.25f
|
||||
}
|
||||
},
|
||||
GOLD("yellow") {
|
||||
override fun getCreditLimit(): Int {
|
||||
return 200000
|
||||
}
|
||||
|
||||
override fun calculateCashbackPercent(): Float {
|
||||
return 0.5f
|
||||
}
|
||||
},
|
||||
PLATINUM("black") {
|
||||
override fun getCreditLimit(): Int {
|
||||
return 300000
|
||||
}
|
||||
|
||||
override fun calculateCashbackPercent(): Float {
|
||||
return 0.75f
|
||||
}
|
||||
};
|
||||
|
||||
abstract fun calculateCashbackPercent(): Float
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.baeldung.enums
|
||||
|
||||
class CardTypeHelper {
|
||||
fun getCardTypeByColor(color: String): CardType? {
|
||||
for (cardType in CardType.values()) {
|
||||
if (cardType.color.equals(color)) {
|
||||
return cardType;
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun getCardTypeByName(name: String): CardType {
|
||||
return CardType.valueOf(name.toUpperCase())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package com.baeldung.enums
|
||||
|
||||
interface ICardLimit {
|
||||
fun getCreditLimit(): Int
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.baeldung.enums
|
||||
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class CardTypeHelperUnitTest {
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByColor_thenSilverCardType() {
|
||||
val cardTypeHelper = CardTypeHelper()
|
||||
Assertions.assertEquals(CardType.SILVER, cardTypeHelper.getCardTypeByColor("gray"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByColor_thenGoldCardType() {
|
||||
val cardTypeHelper = CardTypeHelper()
|
||||
Assertions.assertEquals(CardType.GOLD, cardTypeHelper.getCardTypeByColor("yellow"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByColor_thenPlatinumCardType() {
|
||||
val cardTypeHelper = CardTypeHelper()
|
||||
Assertions.assertEquals(CardType.PLATINUM, cardTypeHelper.getCardTypeByColor("black"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByName_thenSilverCardType() {
|
||||
val cardTypeHelper = CardTypeHelper()
|
||||
Assertions.assertEquals(CardType.SILVER, cardTypeHelper.getCardTypeByName("silver"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByName_thenGoldCardType() {
|
||||
val cardTypeHelper = CardTypeHelper()
|
||||
Assertions.assertEquals(CardType.GOLD, cardTypeHelper.getCardTypeByName("gold"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByName_thenPlatinumCardType() {
|
||||
val cardTypeHelper = CardTypeHelper()
|
||||
Assertions.assertEquals(CardType.PLATINUM, cardTypeHelper.getCardTypeByName("platinum"))
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.baeldung.enums
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class CardTypeUnitTest {
|
||||
|
||||
@Test
|
||||
fun givenSilverCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() {
|
||||
assertEquals(0.25f, CardType.SILVER.calculateCashbackPercent())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenGoldCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() {
|
||||
assertEquals(0.5f, CardType.GOLD.calculateCashbackPercent())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenPlatinumCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() {
|
||||
assertEquals(0.75f, CardType.PLATINUM.calculateCashbackPercent())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenSilverCardType_whenGetCreditLimit_thenReturnCreditLimit() {
|
||||
assertEquals(100000, CardType.SILVER.getCreditLimit())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenGoldCardType_whenGetCreditLimit_thenReturnCreditLimit() {
|
||||
assertEquals(200000, CardType.GOLD.getCreditLimit())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenPlatinumCardType_whenGetCreditLimit_thenReturnCreditLimit() {
|
||||
assertEquals(300000, CardType.PLATINUM.getCreditLimit())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenSilverCardType_whenCheckColor_thenReturnColor() {
|
||||
assertEquals("gray", CardType.SILVER.color)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenGoldCardType_whenCheckColor_thenReturnColor() {
|
||||
assertEquals("yellow", CardType.GOLD.color)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenPlatinumCardType_whenCheckColor_thenReturnColor() {
|
||||
assertEquals("black", CardType.PLATINUM.color)
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -14,17 +14,16 @@ public class UnitTestNamingConventionRule extends AbstractJavaRule {
|
|||
"ManualTest",
|
||||
"JdbcTest",
|
||||
"LiveTest",
|
||||
"UnitTest");
|
||||
"UnitTest",
|
||||
"jmhTest");
|
||||
|
||||
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
||||
String className = node.getImage();
|
||||
Objects.requireNonNull(className);
|
||||
|
||||
if (className.endsWith("Test") || className.endsWith("Tests")) {
|
||||
if (allowedEndings.stream()
|
||||
.noneMatch(className::endsWith)) {
|
||||
addViolation(data, node);
|
||||
}
|
||||
if (className.endsWith("Tests")
|
||||
|| (className.endsWith("Test") && allowedEndings.stream().noneMatch(className::endsWith))) {
|
||||
addViolation(data, node);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
|||
}, webEnvironment = SpringBootTest.WebEnvironment.MOCK)
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("dev")
|
||||
public class FlipControllerTest {
|
||||
public class FlipControllerIntegrationTest {
|
||||
|
||||
@Autowired private MockMvc mvc;
|
||||
|
|
@ -10,8 +10,13 @@ import java.util.*;
|
|||
|
||||
public class Histogram {
|
||||
|
||||
private Map distributionMap;
|
||||
private int classWidth;
|
||||
|
||||
public Histogram() {
|
||||
|
||||
distributionMap = new TreeMap();
|
||||
classWidth = 10;
|
||||
Map distributionMap = processRawData();
|
||||
List yData = new ArrayList();
|
||||
yData.addAll(distributionMap.values());
|
||||
|
@ -46,43 +51,43 @@ public class Histogram {
|
|||
Frequency frequency = new Frequency();
|
||||
datasetList.forEach(d -> frequency.addValue(Double.parseDouble(d.toString())));
|
||||
|
||||
int classWidth = 10;
|
||||
|
||||
Map distributionMap = new TreeMap();
|
||||
List processed = new ArrayList();
|
||||
datasetList.forEach(d -> {
|
||||
double observation = Double.parseDouble(d.toString());
|
||||
|
||||
double observation = Double.parseDouble(d.toString());
|
||||
if(processed.contains(observation))
|
||||
return;
|
||||
|
||||
if(processed.contains(observation))
|
||||
return;
|
||||
long observationFrequency = frequency.getCount(observation);
|
||||
int upperBoundary = (observation > classWidth) ? Math.multiplyExact( (int) Math.ceil(observation / classWidth), classWidth) : classWidth;
|
||||
int lowerBoundary = (upperBoundary > classWidth) ? Math.subtractExact(upperBoundary, classWidth) : 0;
|
||||
String bin = lowerBoundary + "-" + upperBoundary;
|
||||
|
||||
long observationFrequency = frequency.getCount(observation);
|
||||
int upperBoundary = (observation > classWidth) ? Math.multiplyExact( (int) Math.ceil(observation / classWidth), classWidth) : classWidth;
|
||||
int lowerBoundary = (upperBoundary > classWidth) ? Math.subtractExact(upperBoundary, classWidth) : 0;
|
||||
String bin = lowerBoundary + "-" + upperBoundary;
|
||||
updateDistributionMap(lowerBoundary, bin, observationFrequency);
|
||||
|
||||
int prevUpperBoundary = lowerBoundary;
|
||||
int prevLowerBoundary = (lowerBoundary > classWidth) ? lowerBoundary - classWidth : 0;
|
||||
String prevBin = prevLowerBoundary + "-" + prevUpperBoundary;
|
||||
if(!distributionMap.containsKey(prevBin))
|
||||
distributionMap.put(prevBin, 0);
|
||||
|
||||
if(!distributionMap.containsKey(bin)) {
|
||||
distributionMap.put(bin, observationFrequency);
|
||||
}
|
||||
else {
|
||||
long oldFrequency = Long.parseLong(distributionMap.get(bin).toString());
|
||||
distributionMap.replace(bin, oldFrequency + observationFrequency);
|
||||
}
|
||||
|
||||
processed.add(observation);
|
||||
processed.add(observation);
|
||||
|
||||
});
|
||||
|
||||
return distributionMap;
|
||||
}
|
||||
|
||||
private void updateDistributionMap(int lowerBoundary, String bin, long observationFrequency) {
|
||||
|
||||
int prevLowerBoundary = (lowerBoundary > classWidth) ? lowerBoundary - classWidth : 0;
|
||||
String prevBin = prevLowerBoundary + "-" + lowerBoundary;
|
||||
if(!distributionMap.containsKey(prevBin))
|
||||
distributionMap.put(prevBin, 0);
|
||||
|
||||
if(!distributionMap.containsKey(bin)) {
|
||||
distributionMap.put(bin, observationFrequency);
|
||||
}
|
||||
else {
|
||||
long oldFrequency = Long.parseLong(distributionMap.get(bin).toString());
|
||||
distributionMap.replace(bin, oldFrequency + observationFrequency);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Histogram();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Map;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TodoMustacheServiceTest {
|
||||
public class TodoMustacheServiceUnitTest {
|
||||
|
||||
private String executeTemplate(Mustache m, Map<String, Object> context) throws IOException {
|
||||
StringWriter writer = new StringWriter();
|
|
@ -15,7 +15,7 @@ import org.junit.Test;
|
|||
* @author Donato Rimenti
|
||||
*
|
||||
*/
|
||||
public class SingletonSynchronizationUnitTest {
|
||||
public class SingletonSynchronizationIntegrationTest {
|
||||
|
||||
/**
|
||||
* Size of the thread pools used.
|
||||
|
@ -33,7 +33,7 @@ public class SingletonSynchronizationUnitTest {
|
|||
@Test
|
||||
public void givenDraconianSingleton_whenMultithreadInstancesEquals_thenTrue() {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
Set<DraconianSingleton> resultSet = Collections.synchronizedSet(new HashSet<DraconianSingleton>());
|
||||
Set<DraconianSingleton> resultSet = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
// Submits the instantiation tasks.
|
||||
for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
|
||||
|
@ -51,7 +51,7 @@ public class SingletonSynchronizationUnitTest {
|
|||
@Test
|
||||
public void givenDclSingleton_whenMultithreadInstancesEquals_thenTrue() {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
Set<DclSingleton> resultSet = Collections.synchronizedSet(new HashSet<DclSingleton>());
|
||||
Set<DclSingleton> resultSet = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
// Submits the instantiation tasks.
|
||||
for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
|
||||
|
@ -69,7 +69,7 @@ public class SingletonSynchronizationUnitTest {
|
|||
@Test
|
||||
public void givenEarlyInitSingleton_whenMultithreadInstancesEquals_thenTrue() {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
Set<EarlyInitSingleton> resultSet = Collections.synchronizedSet(new HashSet<EarlyInitSingleton>());
|
||||
Set<EarlyInitSingleton> resultSet = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
// Submits the instantiation tasks.
|
||||
for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
|
||||
|
@ -87,7 +87,7 @@ public class SingletonSynchronizationUnitTest {
|
|||
@Test
|
||||
public void givenInitOnDemandSingleton_whenMultithreadInstancesEquals_thenTrue() {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
Set<InitOnDemandSingleton> resultSet = Collections.synchronizedSet(new HashSet<InitOnDemandSingleton>());
|
||||
Set<InitOnDemandSingleton> resultSet = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
// Submits the instantiation tasks.
|
||||
for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
|
||||
|
@ -105,7 +105,7 @@ public class SingletonSynchronizationUnitTest {
|
|||
@Test
|
||||
public void givenEnumSingleton_whenMultithreadInstancesEquals_thenTrue() {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
Set<EnumSingleton> resultSet = Collections.synchronizedSet(new HashSet<EnumSingleton>());
|
||||
Set<EnumSingleton> resultSet = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
// Submits the instantiation tasks.
|
||||
for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
|
5
pom.xml
5
pom.xml
|
@ -373,8 +373,8 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<failurePriority>5</failurePriority> <!-- TODO change to 0 after fixing the project -->
|
||||
<aggregate>true</aggregate>
|
||||
<failurePriority>5</failurePriority>
|
||||
<aggregate>false</aggregate>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
<verbose>true</verbose>
|
||||
<linkXRef>true</linkXRef>
|
||||
|
@ -533,5 +533,4 @@
|
|||
<commons-fileupload.version>1.3</commons-fileupload.version>
|
||||
<junit.jupiter.version>5.0.2</junit.jupiter.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
|||
}, webEnvironment = SpringBootTest.WebEnvironment.MOCK)
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("dev")
|
||||
public class FlipControllerTest {
|
||||
public class FlipControllerIntegrationTest {
|
||||
|
||||
@Autowired private MockMvc mvc;
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
package com.baeldung.persistence;
|
||||
|
||||
import com.baeldung.web.Foo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import com.baeldung.web.Foo;
|
||||
|
||||
public interface FooRepository extends JpaRepository<Foo, Long>, JpaSpecificationExecutor<Foo> {
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.springframework.http.HttpStatus;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import java.util.List;
|
||||
|
@ -14,6 +15,11 @@ import java.util.List;
|
|||
@RestController("/foos")
|
||||
public class FooController {
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
System.out.println("test");
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private FooRepository repo;
|
||||
|
||||
|
|
|
@ -3,10 +3,12 @@ package com.baeldung;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@EnableJpaRepositories("com.baeldung.persistence")
|
||||
public class Example1IntegrationTest {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3,10 +3,12 @@ package com.baeldung;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@EnableJpaRepositories("com.baeldung.persistence")
|
||||
public class Example2IntegrationTest {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.baeldung;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
@ -7,6 +8,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Ignore
|
||||
public class Spring5ApplicationIntegrationTest {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
|
||||
|
@ -13,6 +14,7 @@ import com.baeldung.Spring5Application;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Spring5Application.class)
|
||||
@EnableJpaRepositories("com.baeldung.persistence")
|
||||
public class BeanRegistrationIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.baeldung.jdbc.autogenkey;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -15,6 +16,7 @@ import com.baeldung.jdbc.autogenkey.repository.MessageRepositoryJDBCTemplate;
|
|||
import com.baeldung.jdbc.autogenkey.repository.MessageRepositorySimpleJDBCInsert;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@Ignore
|
||||
public class GetAutoGenKeyByJDBC {
|
||||
|
||||
@Configuration
|
||||
|
|
|
@ -5,6 +5,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -16,18 +17,15 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Spring5Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@Ignore
|
||||
public class JsonbIntegrationTest {
|
||||
@Value("${security.user.name}")
|
||||
private String username;
|
||||
@Value("${security.user.password}")
|
||||
private String password;
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate template;
|
||||
|
||||
@Test
|
||||
public void givenId_whenUriIsPerson_thenGetPerson() {
|
||||
ResponseEntity<Person> response = template.withBasicAuth(username, password)
|
||||
ResponseEntity<Person> response = template
|
||||
.getForEntity("/person/1", Person.class);
|
||||
Person person = response.getBody();
|
||||
assertTrue(person.equals(new Person(2, "Jhon", "jhon1@test.com", 0, LocalDate.of(2019, 9, 9), BigDecimal.valueOf(1500.0))));
|
||||
|
@ -35,8 +33,8 @@ public class JsonbIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void whenSendPostAPerson_thenGetOkStatus() {
|
||||
ResponseEntity<Boolean> response = template.withBasicAuth(username, password)
|
||||
.postForEntity("/person", "{\"birthDate\":\"07-09-2017\",\"email\":\"jhon1@test.com\",\"person-name\":\"Jhon\",\"id\":10}", Boolean.class);
|
||||
ResponseEntity<Boolean> response = template.withBasicAuth("user","password").
|
||||
postForEntity("/person", "{\"birthDate\":\"07-09-2017\",\"email\":\"jhon1@test.com\",\"person-name\":\"Jhon\",\"id\":10}", Boolean.class);
|
||||
assertTrue(response.getBody());
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.baeldung.security;
|
|||
|
||||
import com.baeldung.SpringSecurity5Application;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -31,6 +32,7 @@ public class SecurityIntegrationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@WithMockUser
|
||||
public void whenHasCredentials_thenSeesGreeting() {
|
||||
this.rest.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("Hello, user");
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.reactive.function.server.RequestPredicates;
|
||||
|
@ -16,6 +17,7 @@ import reactor.core.publisher.Mono;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Spring5Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@EnableJpaRepositories("com.baeldung.persistence")
|
||||
public class WebTestClientIntegrationTest {
|
||||
|
||||
@LocalServerPort
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.springframework.web.servlet.ModelAndView;
|
|||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration({"classpath:test-mvc.xml"})
|
||||
public class PassParametersControllerTest {
|
||||
public class PassParametersControllerIntegrationTest {
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Autowired
|
|
@ -5,9 +5,9 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
|
||||
public interface ITransactionalTest {
|
||||
public interface ITransactionalUnitTest {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(ITransactionalTest.class);
|
||||
Logger log = LoggerFactory.getLogger(ITransactionalUnitTest.class);
|
||||
|
||||
@BeforeTransaction
|
||||
default void beforeTransaction() {
|
|
@ -5,7 +5,7 @@ import org.springframework.test.context.ContextConfiguration;
|
|||
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
|
||||
|
||||
@ContextConfiguration(classes = TransactionalTestConfiguration.class)
|
||||
public class TransactionalIntegrationTest extends AbstractTransactionalJUnit4SpringContextTests implements ITransactionalTest {
|
||||
public class TransactionalIntegrationTest extends AbstractTransactionalJUnit4SpringContextTests implements ITransactionalUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenDefaultMethodAnnotatedWithBeforeTransaction_thenDefaultMethodIsExecuted() {
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Intro to Spring Boot Starters](http://www.baeldung.com/spring-boot-starters)
|
||||
- [A Custom Data Binder in Spring MVC](http://www.baeldung.com/spring-mvc-custom-data-binder)
|
||||
- [Introduction to WebJars](http://www.baeldung.com/maven-webjars)
|
||||
- [A Quick Guide to Maven Wrapper](http://www.baeldung.com/maven-wrapper)
|
||||
- [Shutdown a Spring Boot Application](http://www.baeldung.com/spring-boot-shutdown)
|
||||
- [Create a Fat Jar App with Spring Boot](http://www.baeldung.com/deployable-fat-jar-spring-boot)
|
||||
- [Spring Boot Dependency Management with a Custom Parent](http://www.baeldung.com/spring-boot-dependency-management-custom-parent)
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Intro to Spring Boot Starters](http://www.baeldung.com/spring-boot-starters)
|
||||
- [A Custom Data Binder in Spring MVC](http://www.baeldung.com/spring-mvc-custom-data-binder)
|
||||
- [Introduction to WebJars](http://www.baeldung.com/maven-webjars)
|
||||
- [A Quick Guide to Maven Wrapper](http://www.baeldung.com/maven-wrapper)
|
||||
- [Shutdown a Spring Boot Application](http://www.baeldung.com/spring-boot-shutdown)
|
||||
- [Create a Fat Jar App with Spring Boot](http://www.baeldung.com/deployable-fat-jar-spring-boot)
|
||||
- [Spring Boot Dependency Management with a Custom Parent](http://www.baeldung.com/spring-boot-dependency-management-custom-parent)
|
|
@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class KubernetesBackendApplicationTests {
|
||||
public class KubernetesBackendApplicationIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
|
@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class KubernetesFrontendApplicationTests {
|
||||
public class KubernetesFrontendApplicationIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
|
@ -7,7 +7,7 @@ import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
|
|||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class AuthorEventHandlerTest {
|
||||
public class AuthorEventHandlerUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCreateAuthorThenSuccess() {
|
|
@ -7,7 +7,7 @@ import org.mockito.Mockito;
|
|||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class BookEventHandlerTest {
|
||||
public class BookEventHandlerUnitTest {
|
||||
@Test
|
||||
public void whenCreateBookThenSuccess() {
|
||||
Book book = mock(Book.class);
|
|
@ -12,7 +12,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|||
|
||||
import com.baeldung.web.controller.SimpleBookController;
|
||||
|
||||
public class SimpleBookRestControllerTest {
|
||||
public class SimpleBookControllerIntegrationTest {
|
||||
|
||||
private MockMvc mockMvc;
|
||||
private static final String CONTENT_TYPE = "application/json;charset=UTF-8";
|
|
@ -12,7 +12,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|||
|
||||
import com.baeldung.web.controller.SimpleBookController;
|
||||
|
||||
public class SimpleBookControllerTest {
|
||||
public class SimpleBookRestControllerIntegrationTest {
|
||||
|
||||
private MockMvc mockMvc;
|
||||
private static final String CONTENT_TYPE = "application/json;charset=UTF-8";
|
|
@ -6,9 +6,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
|||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.test")
|
||||
public class ConfigTest extends WebMvcConfigurerAdapter {
|
||||
public class ConfigIntegrationTest extends WebMvcConfigurerAdapter {
|
||||
|
||||
public ConfigTest() {
|
||||
public ConfigIntegrationTest() {
|
||||
super();
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
|||
|
||||
import org.baeldung.common.web.AbstractDiscoverabilityLiveTest;
|
||||
import org.baeldung.persistence.model.Foo;
|
||||
import org.baeldung.spring.ConfigTest;
|
||||
import org.baeldung.spring.ConfigIntegrationTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { ConfigTest.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ContextConfiguration(classes = { ConfigIntegrationTest.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ActiveProfiles("test")
|
||||
public class FooDiscoverabilityLiveTest extends AbstractDiscoverabilityLiveTest<Foo> {
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
|||
|
||||
import org.baeldung.common.web.AbstractBasicLiveTest;
|
||||
import org.baeldung.persistence.model.Foo;
|
||||
import org.baeldung.spring.ConfigTest;
|
||||
import org.baeldung.spring.ConfigIntegrationTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { ConfigTest.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ContextConfiguration(classes = { ConfigIntegrationTest.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ActiveProfiles("test")
|
||||
public class FooLiveTest extends AbstractBasicLiveTest<Foo> {
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
|
||||
import org.baeldung.common.web.AbstractBasicLiveTest;
|
||||
import org.baeldung.persistence.model.Foo;
|
||||
import org.baeldung.spring.ConfigTest;
|
||||
import org.baeldung.spring.ConfigIntegrationTest;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
@ -22,7 +22,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { ConfigTest.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ContextConfiguration(classes = { ConfigIntegrationTest.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ActiveProfiles("test")
|
||||
public class FooPageableLiveTest extends AbstractBasicLiveTest<Foo> {
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.baeldung.propertyeditor.creditcard.CreditCard;
|
|||
import com.baeldung.propertyeditor.creditcard.CreditCardEditor;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreditCardEditorTest {
|
||||
public class CreditCardEditorUnitTest {
|
||||
|
||||
private CreditCardEditor creditCardEditor;
|
||||
|
|
@ -11,7 +11,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class SpringSecurityThymeleafApplicationTests {
|
||||
public class SpringSecurityThymeleafApplicationIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
ViewController viewController;
|
|
@ -20,12 +20,12 @@ public class RegisterExtensionSampleExtension implements BeforeAllCallback, Befo
|
|||
|
||||
@Override
|
||||
public void beforeAll(ExtensionContext extensionContext) throws Exception {
|
||||
logger.info("Type " + type + " In beforeAll : " + extensionContext.getDisplayName());
|
||||
logger.info("Type {} In beforeAll : {}", type, extensionContext.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext extensionContext) throws Exception {
|
||||
logger.info("Type " + type + " In beforeEach : " + extensionContext.getDisplayName());
|
||||
logger.info("Type {} In beforeEach : {}", type, extensionContext.getDisplayName());
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
|
|
|
@ -13,7 +13,7 @@ import static java.util.concurrent.Executors.newSingleThreadExecutor;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
public class FutureTest {
|
||||
public class FutureUnitTest {
|
||||
|
||||
private static final String error = "Failed to get underlying value.";
|
||||
private static final String HELLO = "Welcome to Baeldung!";
|
Loading…
Reference in New Issue