src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
FunctionCoreToolsHandlerImpl implements FunctionCoreToolsHandler { protected void installFunctionExtension(File stagingDirector, File basedir) throws AzureExecutionException { commandHandler.runCommandWithReturnCodeCheck( String.format(FUNC_EXTENSIONS_INSTALL_TEMPLATE, basedir.getAbsolutePath()), true, stagingDirector....
@Test public void installFunctionExtension() throws Exception { final CommandHandler commandHandler = mock(CommandHandler.class); final FunctionCoreToolsHandlerImpl functionCoreToolsHandler = new FunctionCoreToolsHandlerImpl(commandHandler); final FunctionCoreToolsHandlerImpl functionCoreToolsHandlerSpy = spy(functionC...
CommandHandlerImpl implements CommandHandler { protected static String[] buildCommand(final String command) { return CommandUtils.isWindows() ? new String[]{"cmd.exe", "/c", command} : new String[]{"sh", "-c", command}; } @Override void runCommandWithReturnCodeCheck(final String command, ...
@Test public void buildCommand() { assertEquals(3, CommandHandlerImpl.buildCommand("cmd").length); }
CommandHandlerImpl implements CommandHandler { protected static ProcessBuilder.Redirect getStdoutRedirect(boolean showStdout) { return showStdout ? ProcessBuilder.Redirect.INHERIT : ProcessBuilder.Redirect.PIPE; } @Override void runCommandWithReturnCodeCheck(final String command, ...
@Test public void getStdoutRedirect() { assertEquals(ProcessBuilder.Redirect.INHERIT, CommandHandlerImpl.getStdoutRedirect(true)); assertEquals(ProcessBuilder.Redirect.PIPE, CommandHandlerImpl.getStdoutRedirect(false)); }
DeployMojo extends AbstractFunctionMojo { protected void configureAppSettings(final Consumer<Map> withAppSettings, final Map appSettings) { if (appSettings != null && !appSettings.isEmpty()) { withAppSettings.accept(appSettings); } } @Override DeploymentType getDeploymentType(); }
@Test public void configureAppSettings() throws Exception { final WithCreate withCreate = mock(WithCreate.class); mojo.configureAppSettings(withCreate::withAppSettings, mojo.getAppSettingsWithDefaultValue()); verify(withCreate, times(1)).withAppSettings(anyMap()); }
CommandHandlerImpl implements CommandHandler { protected void handleExitValue(int exitValue, final List<Long> validReturnCodes, final String errorMessage, final InputStream inputStream) throws AzureExecutionException, IOException { Log.debug("Process exit value: " + exitValue); if (!validReturnCodes.contains(Integer.to...
@Test(expected = Exception.class) public void handleExitValue() throws Exception { final CommandHandlerImpl handler = new CommandHandlerImpl(); handler.handleExitValue(1, Arrays.asList(0L), "", null); }
CommandUtils { public static boolean isWindows() { return SystemUtils.IS_OS_WINDOWS; } static boolean isWindows(); static List<Long> getDefaultValidReturnCodes(); static List<Long> getValidReturnCodes(); }
@Test public void isWindows() { assertEquals(SystemUtils.IS_OS_WINDOWS, CommandUtils.isWindows()); }
CommandUtils { public static List<Long> getDefaultValidReturnCodes() { return Arrays.asList(0L); } static boolean isWindows(); static List<Long> getDefaultValidReturnCodes(); static List<Long> getValidReturnCodes(); }
@Test public void getDefaultValidReturnCodes() throws Exception { assertEquals(2, CommandUtils.getValidReturnCodes().size()); assertEquals(true, CommandUtils.getValidReturnCodes().contains(0L)); }
CommandUtils { public static List<Long> getValidReturnCodes() { return isWindows() ? Arrays.asList(0L, 3221225786L) : Arrays.asList(0L, 130L); } static boolean isWindows(); static List<Long> getDefaultValidReturnCodes(); static List<Long> getValidReturnCodes(); }
@Test public void getValidReturnCodes() { assertEquals(Arrays.asList(0L), CommandUtils.getDefaultValidReturnCodes()); }
FTPUploader { public void uploadDirectoryWithRetries(final String ftpServer, final String username, final String password, final String sourceDirectory, final String targetDirectory, final int maxRetryCount) throws AzureExecutionException { int retryCount = 0; while (retryCount < maxRetryCount) { retryCount++; Log.prom...
@Test public void uploadDirectoryWithRetries() throws Exception { final FTPUploader uploaderSpy = spy(ftpUploader); AzureExecutionException exception = null; doReturn(false).when(uploaderSpy).uploadDirectory(anyString(), anyString(), anyString(), anyString(), anyString()); try { uploaderSpy.uploadDirectoryWithRetries("...
FTPUploader { protected boolean uploadDirectory(final String ftpServer, final String username, final String password, final String sourceDirectoryPath, final String targetDirectoryPath) { Log.debug("FTP username: " + username); try { final FTPClient ftpClient = getFTPClient(ftpServer, username, password); Log.prompt(St...
@Test public void uploadDirectory() throws Exception { final FTPUploader uploaderSpy = spy(ftpUploader); final FTPClient ftpClient = mock(FTPClient.class); doReturn(ftpClient).when(uploaderSpy).getFTPClient(anyString(), anyString(), anyString()); doNothing().when(uploaderSpy).uploadDirectory(any(FTPClient.class), anySt...
FTPUploader { protected FTPClient getFTPClient(final String ftpServer, final String username, final String password) throws IOException { final FTPClient ftpClient = new FTPClient(); ftpClient.connect(ftpServer); ftpClient.login(username, password); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.enterLocalPassi...
@Test public void getFTPClient() throws Exception { Exception caughtException = null; try { ftpUploader.getFTPClient("fakeFTPServer", "username", "password"); } catch (Exception e) { caughtException = e; } finally { assertNotNull(caughtException); } }
Utils { public static OperatingSystemEnum parseOperationSystem(final String os) throws AzureExecutionException { if (StringUtils.isEmpty(os)) { throw new AzureExecutionException("The value of 'os' is empty, please specify it in 'runtime' configuration."); } switch (os.toLowerCase(Locale.ENGLISH)) { case "windows": retu...
@Test public void testParseOperationSystem() throws Exception { assertEquals(OperatingSystemEnum.Windows, Utils.parseOperationSystem("windows")); assertEquals(OperatingSystemEnum.Linux, Utils.parseOperationSystem("Linux")); assertEquals(OperatingSystemEnum.Docker, Utils.parseOperationSystem("dOcker")); } @Test public v...
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { public MavenProject getProject() { return project; } MavenProject getProject(); MavenSession getSession(); String getBuildDirectoryAbsolutePath(); MavenResourcesFiltering getMavenResourcesFiltering(); @Override Settings getSe...
@Test public void getProject() throws Exception { assertEquals(project, mojo.getProject()); }
DeployMojo extends AbstractFunctionMojo { protected ArtifactHandler getArtifactHandler() throws AzureExecutionException { final ArtifactHandlerBase.Builder builder; final DeploymentType deploymentType = getDeploymentType(); getTelemetryProxy().addDefaultProperty(DEPLOYMENT_TYPE_KEY, deploymentType.toString()); switch (...
@Test(expected = AzureExecutionException.class) public void getArtifactHandlerThrowException() throws Exception { getMojoFromPom().getArtifactHandler(); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { public MavenSession getSession() { return session; } MavenProject getProject(); MavenSession getSession(); String getBuildDirectoryAbsolutePath(); MavenResourcesFiltering getMavenResourcesFiltering(); @Override Settings getSe...
@Test public void getSession() throws Exception { assertEquals(session, mojo.getSession()); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { public MavenResourcesFiltering getMavenResourcesFiltering() { return mavenResourcesFiltering; } MavenProject getProject(); MavenSession getSession(); String getBuildDirectoryAbsolutePath(); MavenResourcesFiltering getMavenRes...
@Test public void getMavenResourcesFiltering() throws Exception { assertEquals(filtering, mojo.getMavenResourcesFiltering()); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { public String getBuildDirectoryAbsolutePath() { return buildDirectory.getAbsolutePath(); } MavenProject getProject(); MavenSession getSession(); String getBuildDirectoryAbsolutePath(); MavenResourcesFiltering getMavenResource...
@Test public void getBuildDirectoryAbsolutePath() throws Exception { assertEquals("target", mojo.getBuildDirectoryAbsolutePath()); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { @Override public AuthenticationSetting getAuthenticationSetting() { return authentication; } MavenProject getProject(); MavenSession getSession(); String getBuildDirectoryAbsolutePath(); MavenResourcesFiltering getMavenResour...
@Test public void getAuthenticationSetting() throws Exception { assertEquals(authenticationSetting, mojo.getAuthenticationSetting()); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { public Azure getAzureClient() throws AzureAuthFailureException { if (azure == null) { if (this.authentication != null && (this.authentication.getFile() != null || StringUtils.isNotBlank(authentication.getServerId()))) { Log.wa...
@Test public void getAzureClient() throws Exception { assertEquals(azure, mojo.getAzureClient()); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { @Override public Settings getSettings() { return settings; } MavenProject getProject(); MavenSession getSession(); String getBuildDirectoryAbsolutePath(); MavenResourcesFiltering getMavenResourcesFiltering(); @Override Settin...
@Test public void getMavenSettings() { assertEquals(settings, mojo.getSettings()); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { @Override public String getSubscriptionId() { return subscriptionId; } MavenProject getProject(); MavenSession getSession(); String getBuildDirectoryAbsolutePath(); MavenResourcesFiltering getMavenResourcesFiltering(); @Overr...
@Test public void getSubscriptionId() throws Exception { assertEquals(SUBSCRIPTION_ID, mojo.getSubscriptionId()); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { public TelemetryProxy getTelemetryProxy() { if (telemetryProxy == null) { initTelemetry(); } return telemetryProxy; } MavenProject getProject(); MavenSession getSession(); String getBuildDirectoryAbsolutePath(); MavenResource...
@Test public void getTelemetryProxy() { assertEquals(telemetryProxy, mojo.getTelemetryProxy()); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { public boolean isTelemetryAllowed() { return allowTelemetry; } MavenProject getProject(); MavenSession getSession(); String getBuildDirectoryAbsolutePath(); MavenResourcesFiltering getMavenResourcesFiltering(); @Override Sett...
@Test public void isTelemetryAllowed() throws Exception { assertTrue(!mojo.isTelemetryAllowed()); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { @Override public void execute() throws MojoExecutionException { try { Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler()); final Properties prop = new Properties(); if (isFirstRun(prop)) { infoWith...
@Test public void execute() throws Exception { mojo.execute(); }
DeployMojo extends AbstractFunctionMojo { protected DeploymentType getDeploymentTypeByRuntime() throws AzureExecutionException { final OperatingSystemEnum operatingSystemEnum = getOsEnum(); switch (operatingSystemEnum) { case Docker: return DOCKER; case Linux: return isDedicatedPricingTier() ? RUN_FROM_ZIP : RUN_FROM_B...
@Test public void testGetDeploymentTypeByRuntime() throws AzureExecutionException { doReturn(Windows).when(mojoSpy).getOsEnum(); assertEquals(RUN_FROM_ZIP, mojoSpy.getDeploymentTypeByRuntime()); doReturn(Linux).when(mojoSpy).getOsEnum(); doReturn(true).when(mojoSpy).isDedicatedPricingTier(); assertEquals(RUN_FROM_ZIP, ...
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { protected void handleException(final Exception exception) throws MojoExecutionException { String message = exception.getMessage(); if (StringUtils.isEmpty(message)) { message = exception.toString(); } trackMojoFailure(message)...
@Test public void processException() throws Exception { final String message = "test exception message"; String actualMessage = null; try { mojo.handleException(new Exception(message)); } catch (Exception e) { actualMessage = e.getMessage(); } assertEquals(message, actualMessage); }
AbstractAzureMojo extends AbstractMojo implements TelemetryConfiguration, AuthConfiguration { @Override public Map<String, String> getTelemetryProperties() { final Map<String, String> map = new HashMap<>(); map.put(INSTALLATION_ID_KEY, getInstallationId()); map.put(PLUGIN_NAME_KEY, getPluginName()); map.put(PLUGIN_VERS...
@Test public void getTelemetryProperties() throws Exception { final Map map = mojo.getTelemetryProperties(); assertEquals(5, map.size()); assertTrue(map.containsKey(INSTALLATION_ID_KEY)); assertTrue(map.containsKey(PLUGIN_NAME_KEY)); assertTrue(map.containsKey(PLUGIN_VERSION_KEY)); assertTrue(map.containsKey(SUBSCRIPTI...
SettingsHandlerImpl implements SettingsHandler { @Override public void processSettings(WithCreate withCreate) throws AzureExecutionException { final Map appSettings = mojo.getAppSettings(); if (appSettings != null && !appSettings.isEmpty()) { withCreate.withAppSettings(appSettings); } } SettingsHandlerImpl(final Abstra...
@Test public void processSettings() throws Exception { final WithCreate withCreate = mock(WithCreate.class); handler.processSettings(withCreate); verify(withCreate, times(1)).withAppSettings(ArgumentMatchers.<String, String>anyMap()); } @Test public void processSettings1() throws Exception { final Update update = mock(...
DeploymentSlotHandler { public void createDeploymentSlotIfNotExist() throws AzureExecutionException, AzureAuthFailureException { final DeploymentSlotSetting slotSetting = this.mojo.getDeploymentSlotSetting(); assureValidSlotSetting(slotSetting); final WebApp app = this.mojo.getWebApp(); final String slotName = slotSett...
@Test public void createDeploymentSlotIfNotExist() throws AzureAuthFailureException, AzureExecutionException { final DeploymentSlotHandler handlerSpy = spy(handler); final DeploymentSlotSetting slotSetting = mock(DeploymentSlotSetting.class); final WebApp app = mock(WebApp.class); doReturn(app).when(mojo).getWebApp(); ...
DeploymentSlotHandler { protected void createDeploymentSlot(final WebApp app, final String slotName, final String configurationSource) throws AzureExecutionException { assureValidSlotName(slotName); final DeploymentSlot.DefinitionStages.Blank definedSlot = app.deploymentSlots().define(slotName); final ConfigurationSour...
@Test public void createDeploymentSlotFromParent() throws AzureExecutionException { final DeploymentSlotHandler handlerSpy = spy(handler); final WebApp app = mock(WebApp.class); final DeploymentSlots slots = mock(DeploymentSlots.class); final Blank stage1 = mock(Blank.class); final WithCreate withCreate = mock(WithCrea...
DeploymentSlotHandler { protected void assureValidSlotName(final String slotName) throws AzureExecutionException { final Pattern pattern = Pattern.compile(SLOT_NAME_PATTERN, Pattern.CASE_INSENSITIVE); if (StringUtils.isEmpty(slotName) || !pattern.matcher(slotName).matches()) { throw new AzureExecutionException(INVALID_...
@Test(expected = AzureExecutionException.class) public void assureValidSlotNameThrowException() throws AzureExecutionException { final DeploymentSlotHandler handlerSpy = spy(handler); handlerSpy.assureValidSlotName("@#123"); } @Test public void assureValidSlotName() throws AzureExecutionException { final DeploymentSlot...
DeployMojo extends AbstractFunctionMojo { protected FunctionDeploymentSlot createDeploymentSlot(final FunctionApp functionApp, final FunctionRuntimeHandler runtimeHandler) throws AzureExecutionException, AzureAuthFailureException { Log.info(FUNCTION_SLOT_CREATE_START); final DeploymentSlotSetting slotSetting = getDeplo...
@Test public void testCreateDeploymentSlot() throws AzureAuthFailureException, AzureExecutionException { final FunctionDeploymentSlot slot = mock(FunctionDeploymentSlot.class); final DeploymentSlotSetting slotSetting = new DeploymentSlotSetting(); slotSetting.setName("Test"); doReturn(slotSetting).when(mojoSpy).getDepl...
LinuxRuntimeHandlerImpl extends WebAppRuntimeHandler { @Override public Update updateAppRuntime(WebApp app) throws AzureExecutionException { WebAppUtils.assureLinuxWebApp(app); return app.update().withBuiltInImage(runtime); } private LinuxRuntimeHandlerImpl(final Builder builder); @Override WebApp.DefinitionStages.Wit...
@Test public void updateAppRuntimeTestV2() throws Exception { final WebApp app = mock(WebApp.class); final SiteInner siteInner = mock(SiteInner.class); doReturn(siteInner).when(app).inner(); doReturn("app,linux").when(siteInner).kind(); final WebApp.Update update = mock(WebApp.Update.class); doReturn(update).when(app)....
PublicDockerHubRuntimeHandlerImpl extends WebAppRuntimeHandler { @Override public WebApp.Update updateAppRuntime(final WebApp app) throws AzureExecutionException { WebAppUtils.assureLinuxWebApp(app); return app.update().withPublicDockerHubImage(image); } private PublicDockerHubRuntimeHandlerImpl(final PublicDockerHubR...
@Test public void updateAppRuntimeV2() throws Exception { final SiteInner siteInner = mock(SiteInner.class); doReturn("app,linux").when(siteInner).kind(); final WebApp.Update update = mock(WebApp.Update.class); final WebApp app = mock(WebApp.class); doReturn(siteInner).when(app).inner(); doReturn(update).when(app).upda...
NullRuntimeHandlerImpl implements RuntimeHandler<WebApp> { @Override public WithCreate defineAppWithRuntime() throws AzureExecutionException { throw new AzureExecutionException(NO_RUNTIME_CONFIG); } @Override WithCreate defineAppWithRuntime(); @Override Update updateAppRuntime(final WebApp app); @Override AppServicePl...
@Test public void defineAppWithRuntime() throws Exception { AzureExecutionException exception = null; try { handler.defineAppWithRuntime(); } catch (AzureExecutionException e) { exception = e; } finally { assertNotNull(exception); } }
NullRuntimeHandlerImpl implements RuntimeHandler<WebApp> { @Override public Update updateAppRuntime(final WebApp app) { return null; } @Override WithCreate defineAppWithRuntime(); @Override Update updateAppRuntime(final WebApp app); @Override AppServicePlan updateAppServicePlan(final WebApp app); static final String N...
@Test public void updateAppRuntime() { final WebApp app = mock(WebApp.class); assertNull(handler.updateAppRuntime(app)); }
PrivateRegistryRuntimeHandlerImpl extends WebAppRuntimeHandler { @Override public WebApp.Update updateAppRuntime(final WebApp app) throws AzureExecutionException { WebAppUtils.assureLinuxWebApp(app); return app.update() .withPrivateRegistryImage(image, registryUrl) .withCredentials(dockerCredentialProvider.getUsername(...
@Test public void updateAppRuntimeV2() throws Exception { final SiteInner siteInner = mock(SiteInner.class); doReturn("app,linux").when(siteInner).kind(); final WebApp.UpdateStages.WithCredentials withCredentials = mock(WebApp.UpdateStages.WithCredentials.class); final WebApp.Update update = mock(WebApp.Update.class); ...
WindowsRuntimeHandlerImpl extends WebAppRuntimeHandler { @Override public Update updateAppRuntime(final WebApp app) throws AzureExecutionException { WebAppUtils.assureWindowsWebApp(app); final Update update = app.update(); update.withJavaVersion(javaVersion).withWebContainer(webContainer); return update; } private Win...
@Test public void updateAppRuntimeTestV1() throws Exception { final SiteInner siteInner = mock(SiteInner.class); doReturn("app").when(siteInner).kind(); final WithWebContainer withWebContainer = mock(WithWebContainer.class); final Update update = mock(Update.class); doReturn(withWebContainer).when(update).withJavaVersi...
PackageMojo extends AbstractFunctionMojo { @Override protected void doExecute() throws AzureExecutionException { promptCompileInfo(); final AnnotationHandler annotationHandler = getAnnotationHandler(); Set<Method> methods = null; try { methods = findAnnotatedMethods(annotationHandler); } catch (MalformedURLException e)...
@Test public void doExecute() throws Exception { final PackageMojo mojo = getMojoFromPom(); final PackageMojo mojoSpy = spy(mojo); final Set<Method> methods = new HashSet<>(Arrays.asList(this.getClass().getMethods())); ReflectionUtils.setVariableValueInObject(mojoSpy, "finalName", "artifact-0.1.0"); doReturn(mock(Annot...
PrivateDockerHubRuntimeHandlerImpl extends WebAppRuntimeHandler { @Override public WebApp.Update updateAppRuntime(final WebApp app) throws AzureExecutionException { WebAppUtils.assureLinuxWebApp(app); return app.update() .withPrivateDockerHubImage(image) .withCredentials(dockerCredentialProvider.getUsername(), dockerCr...
@Test public void updateAppRuntimeV2() throws Exception { final WebApp app = mock(WebApp.class); final SiteInner siteInner = mock(SiteInner.class); doReturn(siteInner).when(app).inner(); doReturn("app,linux").when(siteInner).kind(); final WebApp.Update update = mock(WebApp.Update.class); final WebApp.UpdateStages.WithC...
ArtifactHandlerImplV2 extends ArtifactHandlerBase { protected void publishArtifactsViaWarDeploy(final DeployTarget target, final String stagingDirectoryPath, final List<File> warArtifacts) throws AzureExecutionException { if (warArtifacts == null || warArtifacts.size() == 0) { throw new AzureExecutionException( String....
@Test(expected = AzureExecutionException.class) public void publishArtifactsViaWarDeployThrowException() throws AzureExecutionException { final DeployTarget target = mock(DeployTarget.class); final String stagingDirectoryPath = ""; final List<File> warArtifacts = null; buildHandler(); handlerSpy.publishArtifactsViaWarD...
ArtifactHandlerImplV2 extends ArtifactHandlerBase { protected void publishArtifactsViaZipDeploy(final DeployTarget target, final String stagingDirectoryPath) throws AzureExecutionException { if (isJavaSERuntime()) { prepareJavaSERuntime(getAllArtifacts(stagingDirectoryPath)); } final File stagingDirectory = new File(st...
@Test public void publishArtifactsViaZipDeploy() throws AzureExecutionException { final DeployTarget target = mock(DeployTarget.class); final File zipTestDirectory = new File("src/test/resources/artifacthandlerv2"); final String stagingDirectoryPath = zipTestDirectory.getAbsolutePath(); doNothing().when(target).zipDepl...
ArtifactHandlerImplV2 extends ArtifactHandlerBase { protected boolean isJavaSERuntime() { final boolean isJarProject = project != null && project.isJarProject(); if (runtimeSetting == null || runtimeSetting.isEmpty() || isJarProject) { return isJarProject; } final String webContainer = runtimeSetting.getOsEnum() == Ope...
@Test public void isJavaSERuntime() throws Exception { final MavenProject mavenProject = TestUtils.getSimpleMavenProjectForUnitTest(); final IProject project = ProjectUtils.convertCommonProject(mavenProject); final RuntimeSetting runtimeSetting = mock(RuntimeSetting.class); handler = new ArtifactHandlerImplV2.Builder()...
ArtifactHandlerImplV2 extends ArtifactHandlerBase { public void publishWarArtifact(final DeployTarget target, final File warArtifact, final String contextPath) throws AzureExecutionException { final Runnable executor = getRealWarDeployExecutor(target, warArtifact, contextPath); Log.info(String.format("Deploying the war...
@Test public void publishWarArtifact() throws AzureExecutionException { final WebAppDeployTarget target = mock(WebAppDeployTarget.class); final File warArtifact = new File("D:\\temp\\dummypath"); final String contextPath = "dummy"; doNothing().when(target).warDeploy(warArtifact, contextPath); buildHandler(); handlerSpy...
WarArtifactHandlerImpl extends ArtifactHandlerBase { @Override public void publish(final DeployTarget target) throws AzureExecutionException { final File war = getWarFile(); assureWarFileExisted(war); final Runnable warDeployExecutor = ArtifactHandlerUtils.getRealWarDeployExecutor(target, war, getContextPath()); Log.in...
@Test public void publish() throws Exception { final File file = new File(""); final String path = ""; final WebApp appMock = mock(WebApp.class); doReturn(appMock).when(mojo).getWebApp(); doNothing().when(appMock).warDeploy(any(File.class), anyString()); buildHandler(); doReturn(file).when(handlerSpy).getWarFile(); doN...
WarArtifactHandlerImpl extends ArtifactHandlerBase { protected String getContextPath() { String path = contextPath.trim(); if (path.charAt(0) == '/') { path = path.substring(1); } return path; } protected WarArtifactHandlerImpl(final WarArtifactHandlerImpl.Builder builder); @Override void publish(final DeployTarget ta...
@Test public void getContextPath() { doReturn("/").when(mojo).getPath(); buildHandler(); assertEquals(handlerSpy.getContextPath(), ""); doReturn(" / ").when(mojo).getPath(); buildHandler(); assertEquals(handlerSpy.getContextPath(), ""); doReturn("/test").when(mojo).getPath(); buildHandler(); assertEquals(handlerSpy.get...
PackageMojo extends AbstractFunctionMojo { protected AnnotationHandler getAnnotationHandler() { return new AnnotationHandlerImpl(); } @Override List<Resource> getResources(); static final String SEARCH_FUNCTIONS; static final String FOUND_FUNCTIONS; static final String NO_FUNCTIONS; static final String GENERATE_CONFIG...
@Test public void getAnnotationHandler() throws Exception { final PackageMojo mojo = getMojoFromPom(); final AnnotationHandler handler = mojo.getAnnotationHandler(); assertNotNull(handler); assertTrue(handler instanceof AnnotationHandlerImpl); }
WarArtifactHandlerImpl extends ArtifactHandlerBase { protected File getWarFile() { return StringUtils.isNotEmpty(warFile) ? new File(warFile) : new File(project.getArtifactFile().toString()); } protected WarArtifactHandlerImpl(final WarArtifactHandlerImpl.Builder builder); @Override void publish(final DeployTarget tar...
@Test public void getWarFile() { doReturn(null).when(mojo).getWarFile(); doReturn("buildDirectory").when(mojo).getBuildDirectoryAbsolutePath(); final MavenProject projectMock = mock(MavenProject.class); final Build buildMock = mock(Build.class); doReturn(projectMock).when(mojo).getProject(); doReturn(buildMock).when(pr...
WarArtifactHandlerImpl extends ArtifactHandlerBase { protected void assureWarFileExisted(final File war) throws AzureExecutionException { if (!Files.getFileExtension(war.getName()).equalsIgnoreCase("war")) { throw new AzureExecutionException(FILE_IS_NOT_WAR); } if (!war.exists() || !war.isFile()) { throw new AzureExecu...
@Test(expected = AzureExecutionException.class) public void assureWarFileExistedWhenFileExtWrong() throws AzureExecutionException { buildHandler(); handlerSpy.assureWarFileExisted(new File("test.jar")); } @Test(expected = AzureExecutionException.class) public void assureWarFileExistedWhenFileNotExist() throws AzureExec...
JarArtifactHandlerImpl extends ZIPArtifactHandlerImpl { @Override public void publish(DeployTarget deployTarget) throws AzureExecutionException { final File jar = getJarFile(); assureJarFileExisted(jar); try { prepareDeploymentFiles(jar); } catch (IOException e) { throw new AzureExecutionException( String.format("Canno...
@Test public void publish() throws Exception { final DeployTarget deployTarget = new WebAppDeployTarget(this.mojo.getWebApp()); buildHandler(); doNothing().when(handlerSpy).publish(deployTarget); handlerSpy.publish(deployTarget); verify(handlerSpy).publish(deployTarget); } @Test public void publishToDeploymentSlot() th...
JarArtifactHandlerImpl extends ZIPArtifactHandlerImpl { protected void prepareDeploymentFiles(File jar) throws IOException { final File parent = new File(stagingDirectoryPath); parent.mkdirs(); Files.copy(jar, new File(parent, DEFAULT_APP_SERVICE_JAR_NAME)); } protected JarArtifactHandlerImpl(final Builder builder); @...
@Test public void prepareDeploymentFiles() throws IOException { }
JarArtifactHandlerImpl extends ZIPArtifactHandlerImpl { protected File getJarFile() { final String jarFilePath = StringUtils.isNotEmpty(jarFile) ? jarFile : project.getArtifactFile().toString(); return new File(jarFilePath); } protected JarArtifactHandlerImpl(final Builder builder); @Override void publish(DeployTarget...
@Test public void getJarFile() { doReturn("test.jar").when(mojo).getJarFile(); buildHandler(); assertEquals("test.jar", handlerSpy.getJarFile().getName()); final MavenProject project = mock(MavenProject.class); doReturn(project).when(mojo).getProject(); buildHandler(); assertEquals("test.jar", handlerSpy.getJarFile().g...
JarArtifactHandlerImpl extends ZIPArtifactHandlerImpl { protected void assureJarFileExisted(File jar) throws AzureExecutionException { if (!Files.getFileExtension(jar.getName()).equalsIgnoreCase("jar")) { throw new AzureExecutionException(FILE_IS_NOT_JAR); } if (!jar.exists() || !jar.isFile()) { throw new AzureExecutio...
@Test(expected = AzureExecutionException.class) public void assureJarFileExistedWhenFileExtWrong() throws AzureExecutionException { buildHandler(); handlerSpy.assureJarFileExisted(new File("test.jar")); } @Test(expected = AzureExecutionException.class) public void assureJarFileExistedWhenFileNotExist() throws AzureExec...
PackageMojo extends AbstractFunctionMojo { protected String getScriptFilePath() { return new StringBuilder() .append("..") .append("/") .append(getFinalName()) .append(".jar") .toString(); } @Override List<Resource> getResources(); static final String SEARCH_FUNCTIONS; static final String FOUND_FUNCTIONS; static final...
@Test public void getScriptFilePath() throws Exception { final PackageMojo mojo = getMojoFromPom(); final PackageMojo mojoSpy = spy(mojo); ReflectionUtils.setVariableValueInObject(mojoSpy, "finalName", "artifact-0.1.0"); final String finalName = mojoSpy.getScriptFilePath(); assertEquals("../artifact-0.1.0.jar", finalNa...
HandlerFactoryImpl extends HandlerFactory { @Override public RuntimeHandler getRuntimeHandler(final WebAppConfiguration config, final Azure azureClient) throws AzureExecutionException { if (config.getOs() == null) { return new NullRuntimeHandlerImpl(); } final WebAppRuntimeHandler.Builder builder; switch (config.getOs(...
@Test public void getRuntimeHandler() throws AzureExecutionException { final WebAppConfiguration config = mock(WebAppConfiguration.class); final Azure azureClient = mock(Azure.class); final HandlerFactory factory = new HandlerFactoryImpl(); doReturn("").when(config).getAppName(); doReturn("").when(config).getResourceGr...
HandlerFactoryImpl extends HandlerFactory { @Override public SettingsHandler getSettingsHandler(final AbstractWebAppMojo mojo) { return new SettingsHandlerImpl(mojo); } @Override RuntimeHandler getRuntimeHandler(final WebAppConfiguration config, final Azure azureClient); @Override SettingsHandler getSettingsHandler(fi...
@Test public void getSettingsHandler() throws Exception { final HandlerFactory factory = new HandlerFactoryImpl(); final SettingsHandler handler = factory.getSettingsHandler(mojo); assertNotNull(handler); assertTrue(handler instanceof SettingsHandlerImpl); }
HandlerFactoryImpl extends HandlerFactory { @Override public ArtifactHandler getArtifactHandler(final AbstractWebAppMojo mojo) throws AzureExecutionException { switch (SchemaVersion.fromString(mojo.getSchemaVersion())) { case V1: return getV1ArtifactHandler(mojo); case V2: return getV2ArtifactHandler(mojo); default: th...
@Test public void getDefaultArtifactHandler() throws AzureExecutionException { doReturn(project).when(mojo).getProject(); doReturn(DeploymentType.EMPTY).when(mojo).getDeploymentType(); project.setPackaging("jar"); final HandlerFactory factory = new HandlerFactoryImpl(); final ArtifactHandler handler = factory.getArtifa...
HandlerFactoryImpl extends HandlerFactory { @Override public DeploymentSlotHandler getDeploymentSlotHandler(AbstractWebAppMojo mojo) { return new DeploymentSlotHandler(mojo); } @Override RuntimeHandler getRuntimeHandler(final WebAppConfiguration config, final Azure azureClient); @Override SettingsHandler getSettingsHa...
@Test public void getDeploymentSlotHandler() throws AzureExecutionException { final HandlerFactory factory = new HandlerFactoryImpl(); final DeploymentSlotHandler handler = factory.getDeploymentSlotHandler(mojo); assertNotNull(handler); assertTrue(handler instanceof DeploymentSlotHandler); }
HandlerFactoryImpl extends HandlerFactory { protected ArtifactHandlerBase.Builder getArtifactHandlerBuilderFromPackaging(final AbstractWebAppMojo mojo) throws AzureExecutionException { String packaging = mojo.getProject().getPackaging(); if (StringUtils.isEmpty(packaging)) { throw new AzureExecutionException(UNKNOWN_DE...
@Test public void getArtifactHandlerFromPackaging() throws Exception { doReturn(project).when(mojo).getProject(); final HandlerFactoryImpl factory = new HandlerFactoryImpl(); assertTrue(factory.getArtifactHandlerBuilderFromPackaging(mojo).build() instanceof JarArtifactHandlerImpl); } @Test(expected = AzureExecutionExce...
PackageMojo extends AbstractFunctionMojo { protected void writeFunctionJsonFile(final ObjectWriter objectWriter, final String functionName, final FunctionConfiguration config) throws IOException { Log.info(SAVE_FUNCTION_JSON + functionName); final File functionJsonFile = Paths.get(getDeploymentStagingDirectoryPath(), f...
@Test public void writeFunctionJsonFile() throws Exception { final PackageMojo mojo = getMojoFromPom(); final PackageMojo mojoSpy = spy(mojo); doReturn("target/azure-functions").when(mojoSpy).getDeploymentStagingDirectoryPath(); doNothing().when(mojoSpy).writeObjectToFile(isNull(), isNull(), isNotNull()); mojoSpy.write...
RuntimeStackUtils { public static RuntimeStack getRuntimeStack(String javaVersion) { for (final RuntimeStack runtimeStack : getValidRuntimeStacks()) { if (runtimeStack.stack().equals("JAVA") && getJavaVersionFromRuntimeStack(runtimeStack).equalsIgnoreCase(javaVersion)) { return runtimeStack; } } return null; } static ...
@Test public void getRuntimeStackFromString() { assertEquals(RuntimeStackUtils.getRuntimeStack("jre8", "tomcat 8.5"), RuntimeStack.TOMCAT_8_5_JRE8); assertEquals(RuntimeStackUtils.getRuntimeStack("java11", "TOMCAT 9.0"), RuntimeStack.TOMCAT_9_0_JAVA11); assertEquals(RuntimeStackUtils.getRuntimeStack("java11", null), Ru...
RuntimeStackUtils { public static String getWebContainerFromRuntimeStack(RuntimeStack runtimeStack) { final String stack = runtimeStack.stack(); final String version = runtimeStack.version(); return stack.equalsIgnoreCase("JAVA") ? version.split("-")[1] : stack + " " + version.split("-")[0]; } static String getJavaVer...
@Test public void getWebContainerFromRuntimeStack() { assertEquals(RuntimeStackUtils.getWebContainerFromRuntimeStack(RuntimeStack.TOMCAT_8_5_JAVA11), "TOMCAT 8.5"); assertEquals(RuntimeStackUtils.getWebContainerFromRuntimeStack(RuntimeStack.JAVA_8_JRE8), "jre8"); assertEquals(RuntimeStackUtils.getWebContainerFromRuntim...
V2ConfigurationParser extends ConfigurationParser { @Override protected OperatingSystemEnum getOs() throws AzureExecutionException { validate(validator.validateOs()); final RuntimeSetting runtime = mojo.getRuntime(); final String os = runtime.getOs(); if (runtime.isEmpty()) { return null; } switch (os.toLowerCase(Local...
@Test public void getOs() throws AzureExecutionException { final RuntimeSetting runtime = mock(RuntimeSetting.class); doReturn(runtime).when(mojo).getRuntime(); doReturn(true).when(runtime).isEmpty(); assertEquals(null, parser.getOs()); doReturn(false).when(runtime).isEmpty(); doReturn("windows").when(runtime).getOs();...
V2ConfigurationParser extends ConfigurationParser { @Override protected Region getRegion() throws AzureExecutionException { validate(validator.validateRegion()); final String region = mojo.getRegion(); return Region.fromName(region); } V2ConfigurationParser(AbstractWebAppMojo mojo, AbstractConfigurationValidator valida...
@Test public void getRegion() throws AzureExecutionException { doReturn("unknown-region").when(mojo).getRegion(); try { parser.getRegion(); } catch (AzureExecutionException e) { assertEquals(e.getMessage(), "The value of <region> is not supported, please correct it in pom.xml."); } doReturn(Region.US_WEST.name()).when(...
V2ConfigurationParser extends ConfigurationParser { @Override protected RuntimeStack getRuntimeStack() throws AzureExecutionException { validate(validator.validateRuntimeStack()); final RuntimeSetting runtime = mojo.getRuntime(); if (runtime == null || runtime.isEmpty()) { return null; } return runtime.getLinuxRuntime(...
@Test public void getRuntimeStack() throws AzureExecutionException { doReturn(null).when(mojo).getRuntime(); assertNull(parser.getRuntimeStack()); final RuntimeSetting runtime = mock(RuntimeSetting.class); doReturn(true).when(runtime).isEmpty(); doReturn(runtime).when(mojo).getRuntime(); assertNull(parser.getRuntimeSta...
V2ConfigurationParser extends ConfigurationParser { @Override protected String getImage() throws AzureExecutionException { validate(validator.validateImage()); final RuntimeSetting runtime = mojo.getRuntime(); return runtime.getImage(); } V2ConfigurationParser(AbstractWebAppMojo mojo, AbstractConfigurationValidator val...
@Test public void getImage() throws AzureExecutionException { doReturn(null).when(mojo).getRuntime(); try { parser.getImage(); } catch (AzureExecutionException e) { assertEquals(e.getMessage(), "Please configure the <runtime> in pom.xml."); } final RuntimeSetting runtime = mock(RuntimeSetting.class); doReturn("").when(...
V2ConfigurationParser extends ConfigurationParser { @Override protected String getServerId() { final RuntimeSetting runtime = mojo.getRuntime(); if (runtime == null) { return null; } return runtime.getServerId(); } V2ConfigurationParser(AbstractWebAppMojo mojo, AbstractConfigurationValidator validator); }
@Test public void getServerId() { assertNull(parser.getServerId()); final RuntimeSetting runtime = mock(RuntimeSetting.class); doReturn(runtime).when(mojo).getRuntime(); doReturn("serverId").when(runtime).getServerId(); assertEquals("serverId", parser.getServerId()); }
V2ConfigurationParser extends ConfigurationParser { @Override protected String getRegistryUrl() { final RuntimeSetting runtime = mojo.getRuntime(); if (runtime == null) { return null; } return runtime.getRegistryUrl(); } V2ConfigurationParser(AbstractWebAppMojo mojo, AbstractConfigurationValidator validator); }
@Test public void getRegistryUrl() { assertNull(parser.getRegistryUrl()); final RuntimeSetting runtime = mock(RuntimeSetting.class); doReturn(runtime).when(mojo).getRuntime(); doReturn("serverId").when(runtime).getRegistryUrl(); assertEquals("serverId", parser.getRegistryUrl()); }
V2ConfigurationParser extends ConfigurationParser { @Override protected WebContainer getWebContainer() throws AzureExecutionException { validate(validator.validateWebContainer()); final RuntimeSetting runtime = mojo.getRuntime(); return runtime.getWebContainer(); } V2ConfigurationParser(AbstractWebAppMojo mojo, Abstrac...
@Test public void getWebContainer() throws AzureExecutionException { doReturn(null).when(mojo).getRuntime(); try { parser.getWebContainer(); } catch (AzureExecutionException e) { assertEquals(e.getMessage(), "Pleas config the <runtime> in pom.xml."); } final RuntimeSetting runtime = mock(RuntimeSetting.class); doReturn...
V2ConfigurationParser extends ConfigurationParser { @Override protected JavaVersion getJavaVersion() throws AzureExecutionException { validate(validator.validateJavaVersion()); final RuntimeSetting runtime = mojo.getRuntime(); return runtime.getJavaVersion(); } V2ConfigurationParser(AbstractWebAppMojo mojo, AbstractCon...
@Test public void getJavaVersion() throws AzureExecutionException { doReturn(null).when(mojo).getRuntime(); try { parser.getJavaVersion(); } catch (AzureExecutionException e) { assertEquals(e.getMessage(), "Pleas config the <runtime> in pom.xml."); } final RuntimeSetting runtime = mock(RuntimeSetting.class); doReturn(r...
AzureServicePrincipleAuthHelper { static AzureTokenCredentials getAzureServicePrincipleCredentials(AuthConfiguration config) throws InvalidConfigurationException, IOException { if (StringUtils.isBlank(config.getClient())) { throw new IllegalArgumentException("'Client Id' of your service principal is not configured."); ...
@Test public void testGetSPCredentialsBadParameter() throws Exception { final AuthConfiguration config = new AuthConfiguration(); try { AzureServicePrincipleAuthHelper.getAzureServicePrincipleCredentials(config); fail("Should throw IAE"); } catch (IllegalArgumentException ex) { } try { config.setClient("client_id"); Az...
V2ConfigurationParser extends ConfigurationParser { @Override protected List<Resource> getResources() { final Deployment deployment = mojo.getDeployment(); return deployment == null ? null : deployment.getResources(); } V2ConfigurationParser(AbstractWebAppMojo mojo, AbstractConfigurationValidator validator); }
@Test public void getResources() { doReturn(null).when(mojo).getDeployment(); assertNull(parser.getResources()); final List<Resource> resources = new ArrayList<Resource>(); resources.add(new Resource()); final Deployment deployment = mock(Deployment.class); doReturn(deployment).when(mojo).getDeployment(); doReturn(reso...
ConfigurationParser { protected String getAppName() throws AzureExecutionException { validate(validator.validateAppName()); return mojo.getAppName(); } protected ConfigurationParser(final AbstractWebAppMojo mojo, final AbstractConfigurationValidator validator); WebAppConfiguration getWebAppConfiguration(); }
@Test public void getWebAppName() throws AzureExecutionException { doReturn("appName").when(mojo).getAppName(); assertEquals("appName", parser.getAppName()); doReturn("-invalidAppName").when(mojo).getAppName(); try { parser.getAppName(); } catch (AzureExecutionException e) { assertEquals(e.getMessage(), "The <appName> ...
ConfigurationParser { protected String getResourceGroup() throws AzureExecutionException { validate(validator.validateResourceGroup()); return mojo.getResourceGroup(); } protected ConfigurationParser(final AbstractWebAppMojo mojo, final AbstractConfigurationValidator validator); WebAppConfiguration getWebAppConfigurat...
@Test public void getResourceGroup() throws AzureExecutionException { doReturn("resourceGroupName").when(mojo).getResourceGroup(); assertEquals("resourceGroupName", parser.getResourceGroup()); doReturn("invalid**ResourceGroupName").when(mojo).getResourceGroup(); try { parser.getResourceGroup(); } catch (AzureExecutionE...
ConfigurationParser { public WebAppConfiguration getWebAppConfiguration() throws AzureExecutionException { WebAppConfiguration.Builder builder = new WebAppConfiguration.Builder(); final OperatingSystemEnum os = getOs(); if (os == null) { Log.debug("No runtime related config is specified. " + "It will cause error if cre...
@Test public void getWebAppConfiguration() throws AzureExecutionException { final ConfigurationParser parserSpy = spy(parser); doReturn("appName").when(parserSpy).getAppName(); doReturn("resourceGroupName").when(parserSpy).getResourceGroup(); final MavenProject project = mock(MavenProject.class); final MavenResourcesFi...
V1ConfigurationParser extends ConfigurationParser { @Override public OperatingSystemEnum getOs() throws AzureExecutionException { validate(validator.validateOs()); final String linuxRuntime = mojo.getLinuxRuntime(); final String javaVersion = mojo.getJavaVersion(); final ContainerSetting containerSetting = mojo.getCont...
@Test public void getOs() throws AzureExecutionException { assertNull(parser.getOs()); doReturn("1.8").when(mojo).getJavaVersion(); assertEquals(OperatingSystemEnum.Windows, parser.getOs()); doReturn(null).when(mojo).getJavaVersion(); doReturn("linuxRuntime").when(mojo).getLinuxRuntime(); assertEquals(OperatingSystemEn...
V1ConfigurationParser extends ConfigurationParser { @Override protected Region getRegion() throws AzureExecutionException { validate(validator.validateRegion()); if (StringUtils.isEmpty(mojo.getRegion())) { return Region.EUROPE_WEST; } return Region.fromName(mojo.getRegion()); } V1ConfigurationParser(AbstractWebAppMojo...
@Test public void getRegion() throws AzureExecutionException { assertEquals(Region.EUROPE_WEST, parser.getRegion()); doReturn("unknown-region").when(mojo).getRegion(); try { parser.getRegion(); } catch (AzureExecutionException e) { assertEquals(e.getMessage(), "The value of <region> is not correct, please correct it in...
V1ConfigurationParser extends ConfigurationParser { @Override public RuntimeStack getRuntimeStack() throws AzureExecutionException { validate(validator.validateRuntimeStack()); final String linuxRuntime = mojo.getLinuxRuntime(); final RuntimeStack javaSERuntimeStack = RuntimeStackUtils.getRuntimeStack(linuxRuntime); if...
@Test public void getRuntimeStack() throws AzureExecutionException { try { parser.getRuntimeStack(); } catch (AzureExecutionException e) { assertEquals(e.getMessage(), "Please configure the <linuxRuntime> in pom.xml."); } doReturn("tomcat 8.5-jre8").when(mojo).getLinuxRuntime(); assertEquals(RuntimeStack.TOMCAT_8_5_JRE...
V1ConfigurationParser extends ConfigurationParser { @Override public String getImage() throws AzureExecutionException { validate(validator.validateImage()); final ContainerSetting containerSetting = mojo.getContainerSettings(); return containerSetting.getImageName(); } V1ConfigurationParser(AbstractWebAppMojo mojo, Abs...
@Test public void getImage() throws AzureExecutionException { try { parser.getImage(); } catch (AzureExecutionException e) { assertEquals(e.getMessage(), "Please config the <containerSettings> in pom.xml."); } final ContainerSetting containerSetting = mock(ContainerSetting.class); doReturn(containerSetting).when(mojo)....
V1ConfigurationParser extends ConfigurationParser { @Override public String getServerId() { final ContainerSetting containerSetting = mojo.getContainerSettings(); if (containerSetting == null) { return null; } return containerSetting.getServerId(); } V1ConfigurationParser(AbstractWebAppMojo mojo, AbstractConfigurationV...
@Test public void getServerId() { assertNull(parser.getServerId()); final ContainerSetting containerSetting = mock(ContainerSetting.class); doReturn(containerSetting).when(mojo).getContainerSettings(); doReturn("serverId").when(containerSetting).getServerId(); assertEquals("serverId", parser.getServerId()); }
V1ConfigurationParser extends ConfigurationParser { @Override public String getRegistryUrl() { final ContainerSetting containerSetting = mojo.getContainerSettings(); if (containerSetting == null) { return null; } return containerSetting.getRegistryUrl(); } V1ConfigurationParser(AbstractWebAppMojo mojo, AbstractConfigur...
@Test public void getRegistryUrl() { assertNull(parser.getRegistryUrl()); final ContainerSetting containerSetting = mock(ContainerSetting.class); doReturn(containerSetting).when(mojo).getContainerSettings(); doReturn("registryUrl").when(containerSetting).getRegistryUrl(); assertEquals("registryUrl", parser.getRegistryU...
AzureServicePrincipleAuthHelper { static AzureTokenCredentials getCredentialFromAzureCliWithServicePrincipal() throws InvalidConfigurationException, IOException { final JsonObject subscription = getDefaultSubscriptionObject(); final String servicePrincipalName = subscription == null ? null : subscription.get("user").ge...
@Test public void testGetSPCredentials() throws Exception { final File testConfigDir = new File(this.getClass().getResource("/azure-cli/sp/azureProfile.json").getFile()).getParentFile(); TestHelper.injectEnvironmentVariable(Constants.AZURE_CONFIG_DIR, testConfigDir.getAbsolutePath()); final AzureTokenCredentials cred =...
V1ConfigurationParser extends ConfigurationParser { @Override public WebContainer getWebContainer() throws AzureExecutionException { validate(validator.validateWebContainer()); return mojo.getJavaWebContainer(); } V1ConfigurationParser(AbstractWebAppMojo mojo, AbstractConfigurationValidator validator); @Override Operat...
@Test public void getWebContainer() throws AzureExecutionException { try { parser.getWebContainer(); } catch (AzureExecutionException e) { assertEquals(e.getMessage(), "The configuration of <javaWebContainer> in pom.xml is not correct."); } doReturn(WebContainer.TOMCAT_8_5_NEWEST).when(mojo).getJavaWebContainer(); asse...
V1ConfigurationParser extends ConfigurationParser { @Override public JavaVersion getJavaVersion() throws AzureExecutionException { validate(validator.validateJavaVersion()); return JavaVersion.fromString(mojo.getJavaVersion()); } V1ConfigurationParser(AbstractWebAppMojo mojo, AbstractConfigurationValidator validator); ...
@Test public void getJavaVersion() throws AzureExecutionException { try { parser.getJavaVersion(); } catch (AzureExecutionException e) { assertEquals(e.getMessage(), "Please config the <javaVersion> in pom.xml."); } doReturn("1.8").when(mojo).getJavaVersion(); assertEquals(JavaVersion.JAVA_8_NEWEST, parser.getJavaVersi...
DeployMojo extends AbstractWebAppMojo { protected void deployArtifacts(WebAppConfiguration webAppConfiguration) throws AzureAuthFailureException, InterruptedException, AzureExecutionException, IOException { try { util.beforeDeployArtifacts(); final WebApp app = getWebApp(); final DeployTarget target; if (this.isDeployT...
@Test public void deployArtifactsWithNoResources() throws Exception { final DeployMojo mojo = getMojoFromPom("/pom-linux.xml"); final DeployMojo mojoSpy = spy(mojo); final WebApp app = mock(WebApp.class); doReturn("target/classes").when(mojoSpy).getDeploymentStagingDirectoryPath(); doReturn(app).when(mojoSpy).getWebApp...
AuthConfiguration { public List<ConfigurationProblem> validate() { final List<ConfigurationProblem> results = new ArrayList<>(); final String errorMessagePostfix = StringUtils.isNotBlank(serverId) ? "server: " + serverId + " in settings.xml." : "<auth> configuration."; if (StringUtils.isBlank(tenant)) { results.add(new...
@Test public void testValidate() { AuthConfiguration auth = new AuthConfiguration(); auth.setClient("client1"); assertTrue(auth.validate().size() == 2); auth.setTenant("tenant1"); assertTrue(auth.validate().size() == 1); auth.setKey("key1"); assertTrue(auth.validate().size() == 0); auth.setCertificate("certificate1"); ...
AuthConfiguration { public void setClient(String client) { this.client = client; } String getClient(); void setClient(String client); String getTenant(); void setTenant(String tenant); String getKey(); void setKey(String key); String getCertificate(); void setCertificate(String certificate); String getCertificatePassw...
@Test public void testSetClient() { final AuthConfiguration auth = new AuthConfiguration(); auth.setClient("client1"); assertEquals("client1", auth.getClient()); }
AuthConfiguration { public void setTenant(String tenant) { this.tenant = tenant; } String getClient(); void setClient(String client); String getTenant(); void setTenant(String tenant); String getKey(); void setKey(String key); String getCertificate(); void setCertificate(String certificate); String getCertificatePassw...
@Test public void testSetTenant() { final AuthConfiguration auth = new AuthConfiguration(); auth.setTenant("tenant1"); assertEquals("tenant1", auth.getTenant()); }
AuthConfiguration { public void setKey(String key) { this.key = key; } String getClient(); void setClient(String client); String getTenant(); void setTenant(String tenant); String getKey(); void setKey(String key); String getCertificate(); void setCertificate(String certificate); String getCertificatePassword(); void ...
@Test public void testSetKey() { final AuthConfiguration auth = new AuthConfiguration(); auth.setKey("key1"); assertEquals("key1", auth.getKey()); }
AuthConfiguration { public void setCertificate(String certificate) { this.certificate = certificate; } String getClient(); void setClient(String client); String getTenant(); void setTenant(String tenant); String getKey(); void setKey(String key); String getCertificate(); void setCertificate(String certificate); String...
@Test public void testSetCertificate() { final AuthConfiguration auth = new AuthConfiguration(); auth.setCertificate("certificate1"); assertEquals("certificate1", auth.getCertificate()); }
AuthConfiguration { public void setCertificatePassword(String certificatePassword) { this.certificatePassword = certificatePassword; } String getClient(); void setClient(String client); String getTenant(); void setTenant(String tenant); String getKey(); void setKey(String key); String getCertificate(); void setCertifi...
@Test public void testSetCertificatePassword() { final AuthConfiguration auth = new AuthConfiguration(); auth.setCertificatePassword("certificatePassword1"); assertEquals("certificatePassword1", auth.getCertificatePassword()); }
AuthConfiguration { public void setEnvironment(String environment) { this.environment = environment; } String getClient(); void setClient(String client); String getTenant(); void setTenant(String tenant); String getKey(); void setKey(String key); String getCertificate(); void setCertificate(String certificate); String...
@Test public void testSetEnvironment() { final AuthConfiguration auth = new AuthConfiguration(); auth.setEnvironment("environment1"); assertEquals("environment1", auth.getEnvironment()); }
AuthConfiguration { public void setServerId(String serverId) { this.serverId = serverId; } String getClient(); void setClient(String client); String getTenant(); void setTenant(String tenant); String getKey(); void setKey(String key); String getCertificate(); void setCertificate(String certificate); String getCertific...
@Test public void testSetServerId() { final AuthConfiguration auth = new AuthConfiguration(); auth.setServerId("serverId1"); assertEquals("serverId1", auth.getServerId()); }
AuthConfiguration { public void setHttpProxyHost(String httpProxyHost) { this.httpProxyHost = httpProxyHost; } String getClient(); void setClient(String client); String getTenant(); void setTenant(String tenant); String getKey(); void setKey(String key); String getCertificate(); void setCertificate(String certificate)...
@Test public void testSetHttpProxyHost() { final AuthConfiguration auth = new AuthConfiguration(); auth.setHttpProxyHost("httpProxyHost1"); assertEquals("httpProxyHost1", auth.getHttpProxyHost()); }
AuthConfiguration { public void setHttpProxyPort(String httpProxyPort) { this.httpProxyPort = httpProxyPort; } String getClient(); void setClient(String client); String getTenant(); void setTenant(String tenant); String getKey(); void setKey(String key); String getCertificate(); void setCertificate(String certificate)...
@Test public void testSetHttpProxyPort() { final AuthConfiguration auth = new AuthConfiguration(); auth.setHttpProxyPort("8080"); assertEquals("8080", auth.getHttpProxyPort()); }
ListMojo extends AbstractFunctionMojo { @Override protected void doExecute() throws AzureExecutionException { try { Log.info(TEMPLATES_START); printToSystemOut(TEMPLATES_FILE); Log.info(TEMPLATES_END); Log.info(BINDINGS_START); printToSystemOut(BINDINGS_FILE); Log.info(BINDINGS_END); Log.info(RESOURCES_START); printToS...
@Test public void doExecute() throws Exception { PowerMockito.doNothing().when(Log.class); Log.info(any(String.class)); final PrintStream out = mock(PrintStream.class); System.setOut(out); final ListMojo mojo = new ListMojo(); mojo.doExecute(); verify(out, atLeastOnce()).write(any(byte[].class), any(int.class), any(int...
MavenSettingHelper { public static AuthConfiguration getAuthConfigurationFromServer(MavenSession session, SettingsDecrypter settingsDecrypter, String serverId) throws MavenDecryptException { if (StringUtils.isBlank(serverId)) { throw new IllegalArgumentException("Parameter 'serverId' cannot be null or empty."); } final...
@Test public void testGetAuthConfigurationFromServer() throws Exception { final DefaultPlexusCipher cipher = new DefaultPlexusCipher(); final String encryptedKey = cipher.encryptAndDecorate("hello", "fake_master_key"); final String xml = "<configuration>\n" + " <client>df4d03fa-135b-4b7b-932d-2f2ba6449792</client>\n" +...
LocalAuthServer { public void start() throws IOException { if (jettyServer.isStarted()) { return; } try { jettyServer.start(); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new IOException(e); } } LocalAuthServer(); URI getURI(); void start(); void stop(); String waitF...
@Test public void testStart() throws IOException { localAuthServer.stop(); try { localAuthServer.start(); } catch (Exception ex) { fail("Should not fail on after start."); } }
LocalAuthServer { public void stop() throws IOException { semaphore.release(); try { jettyServer.stop(); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new IOException(e); } } LocalAuthServer(); URI getURI(); void start(); void stop(); String waitForCode(); }
@Test public void testStop() throws IOException { localAuthServer.stop(); localAuthServer.stop(); }
AzureCredential { public static AzureCredential fromAuthenticationResult(AuthenticationResult result) { if (result == null) { throw new IllegalArgumentException("Parameter \"result\" cannot be null"); } final AzureCredential token = new AzureCredential(); token.setAccessTokenType(result.getAccessTokenType()); token.set...
@Test public void testFromNullResult() { try { AzureCredential.fromAuthenticationResult(null); fail("Should throw IAE"); } catch (IllegalArgumentException ex) { } }