Skip to content

Added New Class & Test Methods #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions azure-pipelines-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

trigger:
- main

pool:
vmImage: ubuntu-latest

steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
23 changes: 23 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

trigger:
- main
- test

pool:
vmImage: ubuntu-latest

steps:
- task: Maven@4
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
59 changes: 59 additions & 0 deletions src/main/java/com/microsoft/demo/Pipeline_Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.microsoft.demo;

import java.util.Random;

public class Pipeline_Test {

public String MyTestPipeline(String s){
String rev = "";
char [] w = s.toCharArray();

for(int i = s.length()-1; i>=0; i--){
rev = rev.concat(String.valueOf(w[i]));
}
return rev;
}

public char[] random_password(int len)
{
System.out.println("Generating password using random function : ");
System.out.print("Your new password is : ");

// A strong password has Cap_chars, Lower_chars,
// numeric value and symbols. So we are using all of
// them to generate our password
String Capital_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String Small_chars = "abcdefghijklmnopqrstuvwxyz";
String numbers = "0123456789";
String symbols = "!@#$%^&*_=+-/.?<>)";


String values = Capital_chars + Small_chars +
numbers + symbols;

// Using random method
Random rndm_method = new Random();

char[] password = new char[len];

for (int i = 0; i < len; i++)
{
// Use of charAt() method : to get character value
// Use of nextInt() as it is scanning the value as int
password[i] =
values.charAt(rndm_method.nextInt(values.length()));

}
return password;
}

// public static void main(String[] args) {
//
// int length = 10;
// System.out.println(random_password(length));
// }
}




26 changes: 26 additions & 0 deletions src/test/java/MyTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import com.microsoft.demo.Demo;
import com.microsoft.demo.Pipeline_Test;
import org.junit.Test;

public class MyTest {

Pipeline_Test pt = new Pipeline_Test();
String s ="ABCDEFG";
@Test
public void test_method_1() {
Demo d = new Demo();
Expand All @@ -11,4 +15,26 @@ public void test_method_1() {
@Test
public void test_method_2() {
}

@Test
public void test_method_3(){
String rev = pt.MyTestPipeline(s);
if (rev.length()==7)
System.out.println("Test Passed on Length");

}

@Test
public void test_check_length(){
String rev = pt.MyTestPipeline(s);
if (rev.length()<9)
System.out.println("Length Not Matching..!");
}

@Test
public void validateRandomPassword(){
char [] password = pt.random_password(10);
if(password.length==10)
System.out.println("Password Length Matched..!");
}
}