show available nuget versions
[teamcity/dotNetPackagesSupport.git] / nuget-server / src / jetbrains / buildServer / nuget / server / toolRegistry / impl / NuGetToolManagerImpl.java
index 481818b85f3aeb0ffcf25b7f680b4bd477d02aee..145d58bfa397793117e9d50d2e220b84020efa24 100644 (file)
@@ -22,52 +22,42 @@ import org.jetbrains.annotations.NotNull;
 import java.io.File;\r
 import java.util.Arrays;\r
 import java.util.Collection;\r
+import java.util.List;\r
 \r
 /**\r
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 11.08.11 1:07\r
  */\r
 public class NuGetToolManagerImpl implements NuGetToolManager {\r
+  private final AvailableToolsState myAvailables;\r
+\r
+  public NuGetToolManagerImpl(AvailableToolsState availables) {\r
+    myAvailables = availables;\r
+  }\r
+\r
   @NotNull\r
   public Collection<NuGetInstalledTool> getInstalledTools() {\r
-    return Arrays.<NuGetInstalledTool>asList(\r
-            new NuGetInstalledTool() {\r
-              @NotNull\r
-              public File getPath() {\r
-                return new File(".");\r
-              }\r
+    return mockInstalledTools();\r
+  }\r
 \r
-              @NotNull\r
-              public String getId() {\r
-                return "i1";\r
-              }\r
+  @NotNull\r
+  public Collection<NuGetInstallingTool> getInstallingTool() {\r
+    return mockInstallingTools();\r
+  }\r
 \r
-              @NotNull\r
-              public String getVersion() {\r
-                return "i1.2.3.5";\r
-              }\r
-            },\r
-            new NuGetInstalledTool() {\r
-              @NotNull\r
-              public File getPath() {\r
-                return new File(".");\r
-              }\r
 \r
-              @NotNull\r
-              public String getId() {\r
-                return "i2";\r
-              }\r
+  @NotNull\r
+  public Collection<NuGetTool> getAvailableTools() {\r
+    //This must be cached to make if work faster!\r
+    return myAvailables.getAvailable();\r
+  }\r
+\r
+\r
+  public void installTool(@NotNull NuGetTool tool, @NotNull ActionProgress progress) {\r
 \r
-              @NotNull\r
-              public String getVersion() {\r
-                return "i2.4.5.7";\r
-              }\r
-            }\r
-    );\r
   }\r
 \r
-  @NotNull\r
-  public Collection<NuGetInstallingTool> getInstallingTool() {\r
+  private List<NuGetInstallingTool> mockInstallingTools() {\r
     return Arrays.<NuGetInstallingTool>asList(\r
             new NuGetInstallingTool() {\r
               @NotNull\r
@@ -88,39 +78,40 @@ public class NuGetToolManagerImpl implements NuGetToolManager {
     );\r
   }\r
 \r
-  @NotNull\r
-  public Collection<NuGetTool> getAvailableTools() {\r
-    return Arrays.<NuGetTool>asList(\r
-            new NuGetTool() {\r
+  private List<NuGetInstalledTool> mockInstalledTools() {\r
+    return Arrays.<NuGetInstalledTool>asList(\r
+            new NuGetInstalledTool() {\r
+              @NotNull\r
+              public File getPath() {\r
+                return new File(".");\r
+              }\r
+\r
               @NotNull\r
               public String getId() {\r
-                return "a-1";\r
+                return "i1";\r
               }\r
 \r
               @NotNull\r
               public String getVersion() {\r
-                return "a.3.5.6";\r
+                return "i1.2.3.5";\r
               }\r
             },\r
-            new NuGetTool() {\r
+            new NuGetInstalledTool() {\r
+              @NotNull\r
+              public File getPath() {\r
+                return new File(".");\r
+              }\r
+\r
               @NotNull\r
               public String getId() {\r
-                return "a-2";\r
+                return "i2";\r
               }\r
 \r
               @NotNull\r
               public String getVersion() {\r
-                return "a2.5.6.6";\r
+                return "i2.4.5.7";\r
               }\r
             }\r
     );\r
   }\r
-\r
-  public void installTool(@NotNull NuGetTool tool, @NotNull ActionProgress progress) {\r
-\r
-  }\r
-\r
-  public void registerCustomTool(@NotNull NuGetUserTool tool, @NotNull ActionProgress progress) {\r
-\r
-  }\r
 }\r