Skip to content

Commit

Permalink
test: fix failing test AutoOperateTestExample and rename to AutoOpera…
Browse files Browse the repository at this point in the history
…teExampleTest
  • Loading branch information
tangcent authored and Createsequence committed Jul 24, 2023
1 parent 90cc086 commit 5d463f0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
10 changes: 10 additions & 0 deletions crane4j-example/crane4j-spring-boot-starter-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,15 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import cn.crane4j.annotation.Assemble;
import cn.crane4j.annotation.AutoOperate;
import cn.crane4j.annotation.Mapping;
import cn.crane4j.core.container.Container;
import cn.crane4j.core.container.LambdaContainer;
import cn.crane4j.extension.spring.Crane4jApplicationContext;
import cn.crane4j.spring.boot.config.Crane4jAutoConfiguration;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.junit.Assert;
Expand All @@ -15,14 +15,15 @@
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Component;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand All @@ -32,8 +33,14 @@
* @author huangchengxing
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {Crane4jSpringBootStarterExampleApplication.class, AutoOperateTestExample.Service.class})
public class AutoOperateTestExample {
@SpringBootTest(classes = {Crane4jSpringBootStarterExampleApplication.class, AutoOperateExampleTest.Service.class,
Crane4jAutoConfiguration.class})
@TestPropertySource(properties = {
"crane4j.enable-method-result-auto-operate=true",
"crane4j.enable-method-argument-auto-operate=true",
})
@EnableAspectJAutoProxy
public class AutoOperateExampleTest {

@Autowired
private Crane4jApplicationContext context;
Expand All @@ -42,10 +49,6 @@ public class AutoOperateTestExample {

@Before
public void init() {
Supplier<Container<Integer>> supplier = () -> LambdaContainer.forLambda(
"student", ids -> ids.stream()
.collect(Collectors.toMap(Function.identity(), id -> "student" + id))
);
if (!context.containsContainer("student")) {
context.registerContainer("student", () -> LambdaContainer.forLambda(
"student", ids -> ids.stream().collect(Collectors.toMap(Function.identity(), id -> "student" + id))
Expand Down

0 comments on commit 5d463f0

Please sign in to comment.