Skip to content

Commit

Permalink
fix telemetry extension name
Browse files Browse the repository at this point in the history
Signed-off-by: Stephane Bouchet <[email protected]>
  • Loading branch information
sbouchet committed Aug 2, 2024
1 parent 40ec649 commit a9ebf5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.extensions.DefaultPluginDescriptor;
import com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder;
import com.redhat.devtools.intellij.telemetry.core.util.Lazy;

Expand Down Expand Up @@ -49,10 +50,14 @@ public enum TelemetryResult {

private static TelemetryService instance;

private final Lazy<TelemetryMessageBuilder> builder = new Lazy<>(() -> new TelemetryMessageBuilder(PluginManager.getPluginByClass(this.getClass())));
private Lazy<TelemetryMessageBuilder> builder = null;

private TelemetryService() {
// prevent instantiation
if (!ApplicationManager.getApplication().isUnitTestMode()) {
builder = new Lazy<>(() -> new TelemetryMessageBuilder(PluginManager.getPluginByClass(this.getClass())));
} else {
builder = new Lazy<>(() -> new TelemetryMessageBuilder(new DefaultPluginDescriptor("")));
}
}

public static TelemetryService instance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class ApplicationRootNodeOdoTest {
public void before() throws IOException {
this.odo = mock(OdoDelegate.class);
this.rootNode = mock(ApplicationsRootNode.class);
this.fileOperations = mockFileOperations(tempDir, destinationDir);
this.fileOperations = mockFileOperations();
OdoProcessHelper processHelper = mock(OdoProcessHelper.class);
this.rootNodeOdo = new ApplicationRootNodeOdo(odo, false, processHelper, rootNode, fileOperations);
}
Expand Down Expand Up @@ -193,12 +193,12 @@ private void mockGetComponents(ComponentDescriptor descriptor, ApplicationsRootN
.when(rootNode).getLocalComponents();
}

private ApplicationRootNodeOdo.FileOperations mockFileOperations(File tempDir, File destinationDir) throws IOException {
ApplicationRootNodeOdo.FileOperations fileOperations = mock(ApplicationRootNodeOdo.FileOperations.class);
private ApplicationRootNodeOdo.FileOperations mockFileOperations() throws IOException {
ApplicationRootNodeOdo.FileOperations newFileOperations = mock(ApplicationRootNodeOdo.FileOperations.class);
doReturn(tempDir)
.when(fileOperations).createTempDir(any());
.when(newFileOperations).createTempDir(any());
doReturn(destinationDir)
.when(fileOperations).copyTo(any(), any());
return fileOperations;
.when(newFileOperations).copyTo(any(), any());
return newFileOperations;
}
}

0 comments on commit a9ebf5f

Please sign in to comment.