more tests on push command
[teamcity/dotNetPackagesSupport.git] / nuget-agent / src / jetbrains / buildServer / nuget / agent / commands / impl / CommandFactoryImpl.java
index 1b078d09998c63cd30ea1fe7b01870526a9c1459..af7920eefb71765a30fc29c0c0f987d1b47f549d 100644 (file)
@@ -18,14 +18,13 @@ package jetbrains.buildServer.nuget.agent.commands.impl;
 \r
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.nuget.agent.commands.CommandFactory;\r
-import jetbrains.buildServer.nuget.agent.parameters.NuGetFetchParameters;\r
-import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
-import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
+import jetbrains.buildServer.nuget.agent.parameters.*;\r
 import jetbrains.buildServer.util.FileUtil;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
 import java.io.File;\r
 import java.util.ArrayList;\r
+import java.util.Arrays;\r
 import java.util.Collection;\r
 import java.util.List;\r
 \r
@@ -69,13 +68,36 @@ public class CommandFactoryImpl implements CommandFactory {
     return executeNuGet(params.getNuGetParameters(), argz, packagesConfig.getParentFile(), factory);\r
   }\r
 \r
+  @NotNull\r
+  public <T> T createPush(@NotNull final NuGetPublishParameters params,\r
+                          @NotNull final File packagePath,\r
+                          @NotNull final Callback<T> factory) throws RunBuildException {\r
+    final List<String> arguments = new ArrayList<String>();\r
+    arguments.add(packagePath.getPath());\r
+    arguments.add(params.getApiKey());\r
+    if (params.getCreateOnly()) {\r
+      arguments.add("-CreateOnly");\r
+    }\r
+\r
+    return executeNuGet(\r
+            params,\r
+            Arrays.asList(params.getPublishSource()),\r
+            arguments,\r
+            packagePath.getParentFile(),\r
+            factory);\r
+  }\r
+\r
   @NotNull\r
   private <T> T executeNuGet(@NotNull final NuGetFetchParameters nuget,\r
                              @NotNull final Collection<String> arguments,\r
                              @NotNull final File workingDir,\r
                              @NotNull final Callback<T> factory) throws RunBuildException {\r
+    return executeNuGet(nuget, nuget.getNuGetPackageSources(), arguments, workingDir, factory);\r
+  }\r
+\r
+  private <T> T executeNuGet(NuGetParameters nuget, Collection<String> sources, Collection<String> arguments, File workingDir, Callback<T> factory) throws RunBuildException {\r
     final List<String> argz = new ArrayList<String>(arguments);\r
-    for (String source : nuget.getNuGetPackageSources()) {\r
+    for (String source : sources) {\r
       argz.add("-Source");\r
       argz.add(source);\r
     }\r