Skip to content

Commit

Permalink
Feat/mocker handler event (#160)
Browse files Browse the repository at this point in the history
* chore: remove generic
  • Loading branch information
QizhengMo authored Jan 24, 2024
1 parent 6d5884c commit 5f23cfd
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion arex-storage-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<parent>
<artifactId>arex-storage-service</artifactId>
<groupId>com.arextest</groupId>
<version>1.1.6</version>
<version>1.1.7</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion arex-storage-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>arex-storage-service</artifactId>
<groupId>com.arextest</groupId>
<version>1.1.6</version>
<version>1.1.7</version>
</parent>

<profiles>
Expand Down
2 changes: 1 addition & 1 deletion arex-storage-web-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<parent>
<artifactId>arex-storage-service</artifactId>
<groupId>com.arextest</groupId>
<version>1.1.6</version>
<version>1.1.7</version>
</parent>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public <T extends Mocker> boolean saveRecord(@NotNull T item) {
return false;
}

List<MockerSaveHandler<Mocker>> handlers = mockerHandlerFactory.getHandlers(item.getCategoryType());
List<MockerSaveHandler> handlers = mockerHandlerFactory.getHandlers(item.getCategoryType());
if (!CollectionUtils.isEmpty(handlers)) {
for (MockerSaveHandler<Mocker> handler : handlers) {
for (MockerSaveHandler handler : handlers) {
try {
handler.handle(item);
LOGGER.info("Mocker handler success, recordId: {} , handler:{}", item.getRecordId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@Component
@Slf4j
@AllArgsConstructor
public class CoverageMockerHandler implements MockerSaveHandler<AREXMocker> {
public class CoverageMockerHandler implements MockerSaveHandler {
private RepositoryProviderFactory repositoryProviderFactory;
private MockSourceEditionService mockSourceEditionService;
private CoverageRepository coverageRepository;
Expand All @@ -47,7 +47,7 @@ public MockCategoryType getMockCategoryType() {
* if is new case: if it has same path key: replace old case else: store
*/
@Override
public void handle(AREXMocker coverageMocker) {
public void handle(Mocker coverageMocker) {
ScenePoolProvider scenePoolProvider;
Runnable task = null;

Expand Down Expand Up @@ -158,7 +158,7 @@ private void transferEntry(AREXMocker coverageMocker, String incomingCaseId) {
@AllArgsConstructor
private class RecordTask implements Runnable {
private final ScenePoolProvider scenePoolProvider;
private final AREXMocker coverageMocker;
private final Mocker coverageMocker;
private static final long EXPIRATION_EXTENSION_DAYS = 14L;
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

@Component
public class MockerHandlerFactory {
private final Map<MockCategoryType, List<MockerSaveHandler<Mocker>>> categoryHandlers;
public MockerHandlerFactory(@Autowired List<MockerSaveHandler<Mocker>> handlers) {
private final Map<MockCategoryType, List<MockerSaveHandler>> categoryHandlers;
public MockerHandlerFactory(@Autowired List<MockerSaveHandler> handlers) {
this.categoryHandlers = handlers
.stream()
.collect(Collectors.groupingBy(MockerSaveHandler::getMockCategoryType));
}

public List<MockerSaveHandler<Mocker>> getHandlers(MockCategoryType type) {
public List<MockerSaveHandler> getHandlers(MockCategoryType type) {
return categoryHandlers.getOrDefault(type, Collections.emptyList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.arextest.model.mock.MockCategoryType;
import com.arextest.model.mock.Mocker;

public interface MockerSaveHandler<T extends Mocker> {
public interface MockerSaveHandler {

MockCategoryType getMockCategoryType();

void handle(T item);
void handle(Mocker item);
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,5 +408,5 @@
<url>https://github.com/arextest/arex-storage</url>


<version>1.1.6</version>
<version>1.1.7</version>
</project>

0 comments on commit 5f23cfd

Please sign in to comment.