diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/AbstractMybatisPlusTestApplication.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/AbstractMybatisPlusTestApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..fbdc688ffdf3e9da40ac36610e7ed82ee6bcf6ad --- /dev/null +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/AbstractMybatisPlusTestApplication.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.streamquery.stream.plugin.mybatisplus.annotation; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.boot.SpringApplication; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +/** + * MybatisPlusTestApplication less Create Retrieve Update Delete + * + * @author VampireAchao Cizai_ + * @since 2022/5/21 + */ +@ExtendWith(SpringExtension.class) +public abstract class AbstractMybatisPlusTestApplication { + + protected ConfigurableApplicationContext context; + + @BeforeEach + void before() { + context = SpringApplication.run(this.getClass()); + } + + @AfterEach + void after() { + context.close(); + } +} diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByAnnotationAndInterfaceClassTest.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByAnnotationAndInterfaceClassTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b94acd2403894aac8b18d85839393180801a5a6b --- /dev/null +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByAnnotationAndInterfaceClassTest.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.streamquery.stream.plugin.mybatisplus.annotation; + +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.annotation.EnableMybatisPlusPlugin; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.annotation.GenerateMapper; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.configuration.StreamScannerConfigurer; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.mapper.IGenerateMapper; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.RoleInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserRole; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.inner.AddressInfo; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * EnableMybatisPlusPluginByClassesTest + * + * @author KamTo Hung + */ +@EnableAutoConfiguration +@EnableMybatisPlusPlugin( + basePackages = "org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po", + annotation = GenerateMapper.class, + interfaceClass = IGenerateMapper.class) +public class EnableMybatisPlusPluginByAnnotationAndInterfaceClassTest + extends AbstractMybatisPlusTestApplication { + + @Test + void testScanByValue() { + StreamScannerConfigurer bean = context.getBean(StreamScannerConfigurer.class); + assertNotNull(bean); + assertNotNull(bean.getEntityClasses()); + assertTrue(bean.getEntityClasses().contains(RoleInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserInfo.class)); + assertFalse(bean.getEntityClasses().contains(UserRole.class)); + assertTrue(bean.getEntityClasses().contains(AddressInfo.class)); + assertFalse(bean.getEntityClasses().contains(AddressInfo.InnerAddressInfo.class)); + } +} diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByAnnotationTest.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByAnnotationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..028c7108e63fe9ece821fbc09a954b64f5eabec5 --- /dev/null +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByAnnotationTest.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.streamquery.stream.plugin.mybatisplus.annotation; + +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.annotation.EnableMybatisPlusPlugin; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.annotation.GenerateMapper; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.configuration.StreamScannerConfigurer; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.RoleInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserRole; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.inner.AddressInfo; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * EnableMybatisPlusPluginByClassesTest + * + * @author KamTo Hung + */ +@EnableAutoConfiguration +@EnableMybatisPlusPlugin( + basePackages = "org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po", + annotation = GenerateMapper.class) +public class EnableMybatisPlusPluginByAnnotationTest extends AbstractMybatisPlusTestApplication { + + @Test + void testScanByValue() { + StreamScannerConfigurer bean = context.getBean(StreamScannerConfigurer.class); + assertNotNull(bean); + assertNotNull(bean.getEntityClasses()); + assertTrue(bean.getEntityClasses().contains(RoleInfo.class)); + assertFalse(bean.getEntityClasses().contains(UserInfo.class)); + assertFalse(bean.getEntityClasses().contains(UserRole.class)); + assertTrue(bean.getEntityClasses().contains(AddressInfo.class)); + assertFalse(bean.getEntityClasses().contains(AddressInfo.InnerAddressInfo.class)); + } +} diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByBasePackageClassesTest.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByBasePackageClassesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4d4b676332fad149a031c501c651fa02d0c18353 --- /dev/null +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByBasePackageClassesTest.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.streamquery.stream.plugin.mybatisplus.annotation; + +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.annotation.EnableMybatisPlusPlugin; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.configuration.StreamScannerConfigurer; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.RoleInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserRole; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.inner.AddressInfo; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * EnableMybatisPlusPluginByBasePackageClassesTest + * + * @author KamTo Hung + */ +@EnableAutoConfiguration +@EnableMybatisPlusPlugin(basePackageClasses = {UserInfo.class}) +public class EnableMybatisPlusPluginByBasePackageClassesTest + extends AbstractMybatisPlusTestApplication { + + @Test + void testScanByValue() { + StreamScannerConfigurer bean = context.getBean(StreamScannerConfigurer.class); + assertNotNull(bean); + assertNotNull(bean.getEntityClasses()); + assertTrue(bean.getEntityClasses().contains(RoleInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserRole.class)); + assertTrue(bean.getEntityClasses().contains(AddressInfo.class)); + assertFalse(bean.getEntityClasses().contains(AddressInfo.InnerAddressInfo.class)); + } +} diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByBasePackagesGeneralTest.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByBasePackagesGeneralTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5ae5fcfbc2b177cb24a29d05241d3ba8f9754c53 --- /dev/null +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByBasePackagesGeneralTest.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.streamquery.stream.plugin.mybatisplus.annotation; + +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.annotation.EnableMybatisPlusPlugin; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.configuration.StreamScannerConfigurer; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.RoleInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserRole; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.inner.AddressInfo; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * EnableMybatisPlusPluginByBasePackagesGeneralTest + * + * @author KamTo Hung + */ +@EnableAutoConfiguration +@EnableMybatisPlusPlugin(basePackages = "org.dromara.streamquery.stream.plugin.*.pojo.po") +public class EnableMybatisPlusPluginByBasePackagesGeneralTest + extends AbstractMybatisPlusTestApplication { + + @Test + void testScanByValue() { + StreamScannerConfigurer bean = context.getBean(StreamScannerConfigurer.class); + assertNotNull(bean); + assertNotNull(bean.getEntityClasses()); + assertTrue(bean.getEntityClasses().contains(RoleInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserRole.class)); + assertTrue(bean.getEntityClasses().contains(AddressInfo.class)); + assertFalse(bean.getEntityClasses().contains(AddressInfo.InnerAddressInfo.class)); + } +} diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByBasePackagesTest.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByBasePackagesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f5d5ce7247f690ae69eab1c1f434bea22cf3f01e --- /dev/null +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByBasePackagesTest.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.streamquery.stream.plugin.mybatisplus.annotation; + +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.annotation.EnableMybatisPlusPlugin; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.configuration.StreamScannerConfigurer; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.RoleInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserRole; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.inner.AddressInfo; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * EnableMybatisPlusPluginByBasePackagesTest + * + * @author KamTo Hung + */ +@EnableAutoConfiguration +@EnableMybatisPlusPlugin(basePackages = "org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po") +public class EnableMybatisPlusPluginByBasePackagesTest extends AbstractMybatisPlusTestApplication { + + @Test + void testScanByValue() { + StreamScannerConfigurer bean = context.getBean(StreamScannerConfigurer.class); + assertNotNull(bean); + assertNotNull(bean.getEntityClasses()); + assertTrue(bean.getEntityClasses().contains(RoleInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserRole.class)); + assertTrue(bean.getEntityClasses().contains(AddressInfo.class)); + assertFalse(bean.getEntityClasses().contains(AddressInfo.InnerAddressInfo.class)); + } +} diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByClassesTest.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByClassesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..93b0ff6ccf13b747e6119b8a67e39b0d7fab8333 --- /dev/null +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByClassesTest.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.streamquery.stream.plugin.mybatisplus.annotation; + +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.annotation.EnableMybatisPlusPlugin; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.configuration.StreamScannerConfigurer; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.RoleInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserRole; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.inner.AddressInfo; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * EnableMybatisPlusPluginByClassesTest + * + * @author KamTo Hung + */ +@EnableAutoConfiguration +@EnableMybatisPlusPlugin(classes = {UserInfo.class}) +public class EnableMybatisPlusPluginByClassesTest extends AbstractMybatisPlusTestApplication { + + @Test + void testScanByValue() { + StreamScannerConfigurer bean = context.getBean(StreamScannerConfigurer.class); + assertNotNull(bean); + assertNotNull(bean.getEntityClasses()); + assertFalse(bean.getEntityClasses().contains(RoleInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserInfo.class)); + assertFalse(bean.getEntityClasses().contains(UserRole.class)); + assertFalse(bean.getEntityClasses().contains(AddressInfo.class)); + assertFalse(bean.getEntityClasses().contains(AddressInfo.InnerAddressInfo.class)); + } +} diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByInterfaceClassTest.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByInterfaceClassTest.java new file mode 100644 index 0000000000000000000000000000000000000000..dc64e70220d15d93e479586bda0711bde2aa0e82 --- /dev/null +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByInterfaceClassTest.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.streamquery.stream.plugin.mybatisplus.annotation; + +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.annotation.EnableMybatisPlusPlugin; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.configuration.StreamScannerConfigurer; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.mapper.IGenerateMapper; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.RoleInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserRole; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.inner.AddressInfo; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * EnableMybatisPlusPluginByClassesTest + * + * @author KamTo Hung + */ +@EnableAutoConfiguration +@EnableMybatisPlusPlugin( + basePackages = "org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po", + interfaceClass = IGenerateMapper.class) +public class EnableMybatisPlusPluginByInterfaceClassTest + extends AbstractMybatisPlusTestApplication { + + @Test + void testScanByValue() { + StreamScannerConfigurer bean = context.getBean(StreamScannerConfigurer.class); + assertNotNull(bean); + assertNotNull(bean.getEntityClasses()); + assertFalse(bean.getEntityClasses().contains(RoleInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserInfo.class)); + assertFalse(bean.getEntityClasses().contains(UserRole.class)); + assertFalse(bean.getEntityClasses().contains(AddressInfo.class)); + assertFalse(bean.getEntityClasses().contains(AddressInfo.InnerAddressInfo.class)); + } +} diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByValueTest.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByValueTest.java new file mode 100644 index 0000000000000000000000000000000000000000..56dbc048111f1879835ab21535a18ba02ab7f814 --- /dev/null +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/annotation/EnableMybatisPlusPluginByValueTest.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.streamquery.stream.plugin.mybatisplus.annotation; + +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.annotation.EnableMybatisPlusPlugin; +import org.dromara.streamquery.stream.plugin.mybatisplus.engine.configuration.StreamScannerConfigurer; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.RoleInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserInfo; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.UserRole; +import org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po.inner.AddressInfo; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * EnableMybatisPlusPluginByValueTest + * + * @author KamTo Hung + */ +@EnableAutoConfiguration +@EnableMybatisPlusPlugin("org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po") +public class EnableMybatisPlusPluginByValueTest extends AbstractMybatisPlusTestApplication { + + @Test + void testScanByValue() { + StreamScannerConfigurer bean = context.getBean(StreamScannerConfigurer.class); + assertNotNull(bean); + assertNotNull(bean.getEntityClasses()); + assertTrue(bean.getEntityClasses().contains(RoleInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserInfo.class)); + assertTrue(bean.getEntityClasses().contains(UserRole.class)); + assertTrue(bean.getEntityClasses().contains(AddressInfo.class)); + assertFalse(bean.getEntityClasses().contains(AddressInfo.InnerAddressInfo.class)); + } +} diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/pojo/po/UserRole.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/pojo/po/UserRole.java index 12bdf962c79aa486cb50bedf77dad56f44a76459..466f6e81cd721f70351f682a238c967aa3e0a70d 100644 --- a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/pojo/po/UserRole.java +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/pojo/po/UserRole.java @@ -16,9 +16,7 @@ */ package org.dromara.streamquery.stream.plugin.mybatisplus.pojo.po; -import lombok.Builder; import lombok.Data; -import lombok.experimental.Tolerate; /** * UserRole @@ -27,19 +25,9 @@ import lombok.experimental.Tolerate; * @since 2022/5/23 */ @Data -@Builder public class UserRole { - @Tolerate - public UserRole() { - // this is an accessible parameterless constructor. - } - private Long id; private Long userId; private String roleId; - - interface UserRoleInnerInterface {} - - public class UserRoleInnerClass {} } diff --git a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/pojo/po/inner/AddressInfo.java b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/pojo/po/inner/AddressInfo.java index d265af5f07fe73e59c8ecb8c6fff35fec712e9cc..d902058f6c8eb052e3c4588c23d4d1f17f40bf44 100644 --- a/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/pojo/po/inner/AddressInfo.java +++ b/stream-plugin/stream-plugin-mybatis-plus/src/test/java/org/dromara/streamquery/stream/plugin/mybatisplus/pojo/po/inner/AddressInfo.java @@ -34,4 +34,9 @@ public class AddressInfo { private String id; private String address; + + @Data + public static class InnerAddressInfo { + private String id; + } }