Search in sources :

Example 1 with AutoRefreshPluginConfigImpl

use of com.megaease.easeagent.plugin.api.config.AutoRefreshPluginConfigImpl in project easeagent by megaease.

the class MongoBaseTest method before.

@Before
public void before() {
    EaseAgent.initializeContextSupplier.get().clear();
    config = new AutoRefreshPluginConfigImpl();
    IPluginConfig iPluginConfig = mock(IPluginConfig.class);
    when(iPluginConfig.enabled()).thenReturn(true);
    when(iPluginConfig.namespace()).thenReturn("mongodb");
    when(iPluginConfig.domain()).thenReturn("observability");
    config.onChange(null, iPluginConfig);
    Context context = EaseAgent.getContext();
    ContextUtils.setBeginTime(context);
    MockEaseAgent.cleanLastSpan();
    clusterId = new ClusterId("local-cluster");
    serverAddress = new ServerAddress("127.0.0.1", 2020);
    serverId = new ServerId(clusterId, serverAddress);
    this.connectionDescription = new ConnectionDescription(serverId);
    Map<String, Object> map = new HashMap<>();
    map.put("collection", collection);
    BsonDocument bsonDocument = BsonDocument.parse(JsonUtil.toJson(map));
    this.startedEvent = new CommandStartedEvent(this.requestId, this.connectionDescription, this.dbName, this.cmdName, bsonDocument);
}
Also used : Context(com.megaease.easeagent.plugin.api.Context) ClusterId(com.mongodb.connection.ClusterId) HashMap(java.util.HashMap) ServerAddress(com.mongodb.ServerAddress) ConnectionDescription(com.mongodb.connection.ConnectionDescription) ServerId(com.mongodb.connection.ServerId) BsonDocument(org.bson.BsonDocument) CommandStartedEvent(com.mongodb.event.CommandStartedEvent) AutoRefreshPluginConfigImpl(com.megaease.easeagent.plugin.api.config.AutoRefreshPluginConfigImpl) IPluginConfig(com.megaease.easeagent.plugin.api.config.IPluginConfig) Before(org.junit.Before)

Aggregations

Context (com.megaease.easeagent.plugin.api.Context)1 AutoRefreshPluginConfigImpl (com.megaease.easeagent.plugin.api.config.AutoRefreshPluginConfigImpl)1 IPluginConfig (com.megaease.easeagent.plugin.api.config.IPluginConfig)1 ServerAddress (com.mongodb.ServerAddress)1 ClusterId (com.mongodb.connection.ClusterId)1 ConnectionDescription (com.mongodb.connection.ConnectionDescription)1 ServerId (com.mongodb.connection.ServerId)1 CommandStartedEvent (com.mongodb.event.CommandStartedEvent)1 HashMap (java.util.HashMap)1 BsonDocument (org.bson.BsonDocument)1 Before (org.junit.Before)1