Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发布proto、geom-spring-boot-starter失败 #38

Merged
merged 7 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set Version
run: mvn -B versions:set -DnewVersion=$GITHUB_REF_NAME
- name: Publish Java package
run: mvn -B deploy -pl geom-proto,geom-spring-boot-starter -P release -DskipTests=true
run: mvn -B deploy -P release -DskipTests=true
env:
MAVEN_USERNAME: ${{ vars.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
Expand Down
7 changes: 7 additions & 0 deletions geom-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@
</extraDirectories>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Expand Down
18 changes: 18 additions & 0 deletions geom-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,23 @@
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
<classifier>jakarta</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ public M get() {
}

public T partialUpdate(T target) {
T entity = this.get().getReferenceById(target.getId());
T entity = this.get().findById(target.getId())
.orElseThrow();
this.getCopier().copy(target, entity);
this.get().save(entity);
return entity;
}

public Page<T> findAll(ODataQueryOption odata) {
return this.findAll(odata, BaseSpecs.TRUE(), Sort.unsorted());
return this.findAll(odata, null, null);
}

protected Page<T> findAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.github.xezzon.geom.dict.DictGrpc.DictStub;
import io.grpc.stub.StreamObserver;
import java.util.concurrent.CountDownLatch;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.jetbrains.annotations.TestOnly;
Expand All @@ -19,12 +18,16 @@
public class DictRpcHandler implements DictImporter, RpcTrait {

@TestOnly
@Getter(onMethod_ = {@TestOnly})
private final CountDownLatch countDownLatch = new CountDownLatch(1);

@GrpcClient("dict")
private DictStub dictStub;

@TestOnly
public CountDownLatch getCountDownLatch() {
return this.countDownLatch;
}

@Override
public void importDict(DictImportReqList reqList) {
dictStub.importDict(reqList, new StreamObserver<>() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package io.github.xezzon.geom;

import io.github.xezzon.geom.common.trait.ExcludeDbTrait;
import io.github.xezzon.geom.dict.EnableDictScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;

/**
* @author xezzon
*/
@SpringBootApplication
@EnableDictScan()
@Import(ExcludeDbTrait.class)
public class TestApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package io.github.xezzon.geom.common.jpa;

import cn.hutool.core.util.RandomUtil;
import io.github.xezzon.geom.common.odata.ODataQueryOption;
import io.github.xezzon.geom.common.odata.ODataRequestParam;
import jakarta.annotation.Resource;
import java.util.Optional;
import java.util.UUID;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;

/**
* @author xezzon
*/
@SpringBootTest
class BaseDAOTest {

@Resource
private TestEntityDAO testEntityDAO;
@Resource
private TestEntityRepository repository;


@Test
void partialUpdate() {
TestEntity testEntity = new TestEntity();
testEntity.setField1(RandomUtil.randomString(8));
testEntity.setField2(RandomUtil.randomString(8));
repository.save(testEntity);
TestEntity testEntity1 = new TestEntity();
testEntity1.setId(testEntity.getId());
testEntity1.setField1(RandomUtil.randomString(8));
testEntityDAO.partialUpdate(testEntity1);

Optional<TestEntity> result = repository.findById(testEntity.getId());
Assertions.assertTrue(result.isPresent());
Assertions.assertEquals(testEntity1.getField1(), result.get().getField1());
Assertions.assertEquals(testEntity.getField2(), result.get().getField2());
}

@Test
void findAll() {
final int loopTime = 16;
for (int i = 0; i < loopTime; i++) {
TestEntity testEntity = new TestEntity();
if (RandomUtil.randomBoolean()) {
testEntity.setId(UUID.randomUUID().toString());
}
testEntity.setField1(RandomUtil.randomString(8));
testEntity.setField2(RandomUtil.randomString(8));
repository.save(testEntity);
}
final int pageNum = 2;
final int pageSize = 2;
ODataRequestParam param = new ODataRequestParam(pageSize, pageSize * pageNum);
ODataQueryOption odata = param.into();
Page<TestEntity> page = testEntityDAO.findAll(odata);
Assertions.assertEquals(loopTime, page.getTotalElements());
Assertions.assertEquals(pageSize, page.getContent().size());
Assertions.assertEquals(pageSize, page.getSize());
Assertions.assertEquals(pageNum, page.getNumber());

ODataQueryOption odata1 = ODataQueryOption.builder()
.top(pageSize)
.skip(pageNum * pageSize)
.build();
Page<TestEntity> page1 = testEntityDAO.findAll(odata1, BaseSpecs.FALSE(), null);
Assertions.assertEquals(0, page1.getTotalElements());
Assertions.assertEquals(0, page1.getContent().size());
Assertions.assertEquals(pageSize, page1.getSize());
Assertions.assertEquals(pageNum, page1.getNumber());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.github.xezzon.geom.common.jpa;

import io.github.xezzon.geom.common.constant.DatabaseConstant;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
* @author xezzon
*/
@Getter
@Setter
@ToString
@Entity
@Table(name = "test_entity")
public class TestEntity implements IEntity<String> {

@Id
@Column(name = "id", nullable = false, updatable = false, length = DatabaseConstant.ID_LENGTH)
@IdGenerator
private String id;
@Column(name = "field1")
private String field1;
@Column(name = "field2")
private String field2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.github.xezzon.geom.common.jpa;

import com.querydsl.core.types.dsl.EntityPathBase;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Repository;

/**
* @author xezzon
*/
@Repository
public class TestEntityDAO extends BaseDAO<TestEntity, String, TestEntityRepository> {

protected TestEntityDAO(TestEntityRepository repository) {
super(repository);
}

@Override
public ICopier<TestEntity> getCopier() {
return Copier.INSTANCE;
}

@Override
protected EntityPathBase<TestEntity> getQuery() {
return QTestEntity.testEntity;
}

@Mapper
interface Copier extends ICopier<TestEntity> {

Copier INSTANCE = Mappers.getMapper(Copier.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.github.xezzon.geom.common.jpa;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

/**
* @author xezzon
*/
@Repository
public interface TestEntityRepository extends
JpaRepository<TestEntity, String>,
JpaSpecificationExecutor<TestEntity> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.github.xezzon.geom.common.redis;

import static org.junit.jupiter.api.Assertions.*;

import io.github.xezzon.geom.common.jpa.TestEntity;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

/**
* @author xezzon
*/
@SpringBootTest
class RedisTemplateFactoryTest {

@Resource
private RedisTemplateFactory factory;

@Test
void of() {
RedisTemplate<String, TestEntity> redisTemplate = factory.of(TestEntity.class);
assertNotNull(redisTemplate);
}

@Test
void genericRedisTemplate() {
RedisTemplate<String, TestEntity> redisTemplate = factory.genericRedisTemplate();
assertNotNull(redisTemplate);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.github.xezzon.geom.common.util;

import static org.junit.jupiter.api.Assertions.*;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
* @author xezzon
*/
class ResourceUtilTest {

@Test
void getResourceFromClasspath() throws IOException {
Path resource = ResourceUtil.getResourceFromClasspath("test.txt");
byte[] bytes = Files.readAllBytes(resource);
String string = new String(bytes);
Assertions.assertEquals("hello\n", string);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REDIS_URL: localhost:6379
1 change: 1 addition & 0 deletions geom-spring-boot-starter/src/test/resources/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down
7 changes: 7 additions & 0 deletions report-aggregate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>