forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#2167] refactor: refactor TestGravitinoConnector to enable Sta…
…ticGuardedByInstance error-prone
- Loading branch information
Showing
6 changed files
with
77 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...src/test/java/com/datastrato/gravitino/trino/connector/TestGravitinoConnectorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
|
||
package com.datastrato.gravitino.trino.connector; | ||
|
||
import io.trino.spi.connector.Connector; | ||
import io.trino.spi.connector.ConnectorContext; | ||
import java.util.Map; | ||
|
||
class TestGravitinoConnectorFactory extends GravitinoConnectorFactory { | ||
private Runnable hook; | ||
|
||
void setHook(Runnable hook) { | ||
this.hook = hook; | ||
} | ||
|
||
@Override | ||
public Connector create( | ||
String catalogName, Map<String, String> requiredConfig, ConnectorContext context) { | ||
Connector connector = super.create(catalogName, requiredConfig, context); | ||
hook.run(); | ||
return connector; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...connector/src/test/java/com/datastrato/gravitino/trino/connector/TestGravitinoPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
|
||
package com.datastrato.gravitino.trino.connector; | ||
|
||
import com.datastrato.gravitino.trino.connector.catalog.CatalogConnectorManager; | ||
import com.google.common.collect.ImmutableList; | ||
import io.trino.spi.connector.ConnectorFactory; | ||
|
||
public class TestGravitinoPlugin extends GravitinoPlugin { | ||
private TestGravitinoConnectorFactory factory; | ||
private CatalogConnectorManager catalogConnectorManager; | ||
|
||
@Override | ||
public Iterable<ConnectorFactory> getConnectorFactories() { | ||
factory = new TestGravitinoConnectorFactory(); | ||
factory.setHook(this::init); | ||
return ImmutableList.of(factory); | ||
} | ||
|
||
private void init() { | ||
catalogConnectorManager = factory.getCatalogConnectorManager(); | ||
} | ||
|
||
public CatalogConnectorManager getCatalogConnectorManager() { | ||
return catalogConnectorManager; | ||
} | ||
} |