diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index f2c5a7f..a07c372 100644 --- a/pom.xml +++ b/pom.xml @@ -37,5 +37,30 @@ + + src/main/java + src/test/java + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.7.0.174 + 6 + + + + + + \ No newline at end of file diff --git a/src/main/java/Main_Package/Book.java b/src/main/java/Main_Package/Book.java deleted file mode 100644 index c74357e..0000000 --- a/src/main/java/Main_Package/Book.java +++ /dev/null @@ -1,52 +0,0 @@ -package Main_Package; - -public class Book { - - public String title; - public String author; - public String ISBN; - public String Signature; - - public Book() - { - ISBN = ""; - title = "None"; - author = "Nobody"; - } - - public void set_title(String my_title) - { - this.title = my_title; - } - public void set_Sig(String Sig) - { - this.Signature = Sig; - } - public void set_author(String my_author) - { - this.author = my_author; - } - public void set_ISBN(String my_ISBN) - { - this.ISBN = my_ISBN; - } - - - public String getISBN() - { - return this.ISBN; - } - public String getAuthor() - { - return this.author; - } - public String getTitle() - { - return this.title; - } - public String getSig() - { - return this.Signature; - } - -} diff --git a/src/main/java/Main_Package/Books_Library.java b/src/main/java/Main_Package/Books_Library.java deleted file mode 100644 index 0226e32..0000000 --- a/src/main/java/Main_Package/Books_Library.java +++ /dev/null @@ -1,29 +0,0 @@ -package Main_Package; -import java.util.ArrayList; - -public class Books_Library { - - public static ArrayList Books =new ArrayList() ;; - Book book =new Book(); - /* - * Book bk=new Book(); Book bk2=new Book(); Book bk3=new Book(); Book bk4=new - * Book(); - */ - - public Books_Library() - { - - } - - - - public void addBook(String title,String author,String isbn,String sign) - { - book.set_author(author); - book.set_ISBN(isbn); - book.set_title(title); - book.set_Sig(sign); - Books.add(book); - } - -} diff --git a/src/main/java/Main_Package/login.java b/src/main/java/Main_Package/login.java deleted file mode 100644 index d5c23de..0000000 --- a/src/main/java/Main_Package/login.java +++ /dev/null @@ -1,19 +0,0 @@ -package Main_Package; - -public class login { - public String username; - public String password; - public String entered_username; - public String entered_passsword; - public void set_username(String myusername){ - this.username = myusername; - } - - public void set_password(String mypassword){ - this.password = mypassword; - } - - - -} - diff --git a/src/main/java/Main_Package/logout.java b/src/main/java/Main_Package/logout.java deleted file mode 100644 index 67a9a60..0000000 --- a/src/main/java/Main_Package/logout.java +++ /dev/null @@ -1,10 +0,0 @@ -package Main_Package; - -public class logout { - - public static Boolean loggedout; - public void logoutt(){ - System.out.println("logged out successfully"); - loggedout = true; - } -} diff --git a/src/main/java/mainpackage/Book.java b/src/main/java/mainpackage/Book.java new file mode 100644 index 0000000..5bc1d1b --- /dev/null +++ b/src/main/java/mainpackage/Book.java @@ -0,0 +1,52 @@ +package mainpackage; + +public class Book { + + private String title; + private String author; + private String isbn; + private String signature; + + public Book() + { + isbn = ""; + title = "None"; + author = "Nobody"; + } + + public void setTitle(String mytitle) + { + this.title = mytitle; + } + public void setSig(String sig) + { + this.signature = sig; + } + public void setAuthor(String myauthor) + { + this.author = myauthor; + } + public void setIsbn(String myisbn) + { + this.isbn = myisbn; + } + + + public String getISBN() + { + return this.isbn; + } + public String getAuthor() + { + return this.author; + } + public String getTitle() + { + return this.title; + } + public String getSig() + { + return this.signature; + } + +} diff --git a/src/main/java/mainpackage/BooksLibrary.java b/src/main/java/mainpackage/BooksLibrary.java new file mode 100644 index 0000000..00448b7 --- /dev/null +++ b/src/main/java/mainpackage/BooksLibrary.java @@ -0,0 +1,26 @@ +package mainpackage; +import java.util.ArrayList; + +public class BooksLibrary { + + public static ArrayList books2 =new ArrayList() ;; + private Book book =new Book(); + + + public BooksLibrary() + { + // do nothing + } + + + + public void addBook(String title,String author,String isbn,String sign) + { + book.setAuthor(author); + book.setIsbn(isbn); + book.setTitle(title); + book.setSig(sign); + books2.add(book); + } + +} diff --git a/src/main/java/mainpackage/Login.java b/src/main/java/mainpackage/Login.java new file mode 100644 index 0000000..1bf0f14 --- /dev/null +++ b/src/main/java/mainpackage/Login.java @@ -0,0 +1,53 @@ +package mainpackage; + +public class Login { + private String username; + private String password; + private String enteredUsername; + private String enteredPasssword; + + + public String getEnteredUsername() { + return enteredUsername; + } + + public String getEnteredPasssword() { + return enteredPasssword; + } + + + + + public void setEnteredUsername(String enteredUsername) { + this.enteredUsername = enteredUsername; + } + + public void setEnteredPasssword(String enteredPasssword) { + this.enteredPasssword = enteredPasssword; + } + + + + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } + + + + + public void setUsername(String myusername){ + this.username = myusername; + } + + public void setPassword(String mypassword){ + this.password = mypassword; + } + + + +} + diff --git a/src/main/java/mainpackage/Logout.java b/src/main/java/mainpackage/Logout.java new file mode 100644 index 0000000..c295d88 --- /dev/null +++ b/src/main/java/mainpackage/Logout.java @@ -0,0 +1,23 @@ +package mainpackage; +import java.util.logging.Logger; +import java.util.logging.Level; + +public class Logout { + + static Logger logger = Logger.getLogger(Logout.class.getName()); + + public void setLoggedout(Boolean loggedout) { + this.loggedout = loggedout; + } + + public Boolean getLoggedout() { + return loggedout; + } + + private Boolean loggedout; + public void logoutt(){ + + logger.log(Level.WARNING,"logged out successfully"); + loggedout = true; + } +} diff --git a/src/test/java/Test_Package/AddBookSteps.java b/src/test/java/Test_Package/AddBookSteps.java index 5dd1727..dfdfb96 100644 --- a/src/test/java/Test_Package/AddBookSteps.java +++ b/src/test/java/Test_Package/AddBookSteps.java @@ -3,17 +3,17 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import Main_Package.Book; -import Main_Package.Books_Library; +import mainpackage.Book; +import mainpackage.BooksLibrary; import static org.junit.Assert.assertTrue; -import Main_Package.Books_Library; + public class AddBookSteps { boolean Added=false; char[] ISBN ; int num=10; int tot=0; String check=""; - Books_Library library = new Books_Library(); + BooksLibrary library = new BooksLibrary(); @Given("the administrator is logged in") public void the_administrator_is_logged_in() { @@ -26,7 +26,7 @@ public void the_administrator_is_logged_in() { public void the_user_enter_the_the_and_the_and_signature_is(String title, String author, String isbn, String sign) { System.out.printf("----------- %s ----------- %s ----------- %s ----------- %s ----------- %n" , title,author,isbn,sign ); boolean flag=false; - for (Book book:Books_Library.Books) + for (Book book: BooksLibrary.books2) { if (isbn.equals(book.getISBN()) ) {flag=true; } @@ -62,10 +62,11 @@ public void the_user_enter_the_the_and_the_and_signature_is(String title, String @Then("if the ISBN is valid the book will be added") public void if_the_isbn_is_valid_the_book_will_be_added() { if (Added==true) - { assertTrue(Added == true); + { assertTrue(Added ); System.out.println("-----------Book Added Sucsessfully-----------"); } else{ + assertTrue(!Added); System.out.println("-----------Book can't be added because the ISBN is invalid----------- "); } } @@ -94,7 +95,7 @@ public void the_user_enter_the_the_and_the_and_signature_is_and_he_is_not_logged @Then("the book will not be added") public void the_book_will_not_be_added() { - assertTrue(Added == false); + assertTrue(!Added ); System.out.println("-----------Book Can't be added-----------"); } diff --git a/src/test/java/Test_Package/LoginSteps.java b/src/test/java/Test_Package/LoginSteps.java index 48dd9c2..06ca2f7 100644 --- a/src/test/java/Test_Package/LoginSteps.java +++ b/src/test/java/Test_Package/LoginSteps.java @@ -1,21 +1,20 @@ package Test_Package; -import io.cucumber.java.en.And; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import Main_Package.login; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; +import mainpackage.Login; + +import static org.junit.Assert.*; public class LoginSteps { - login L = new login(); + Login L = new Login(); @Given("the username is {string} and the password is {string}") public void the_username_is_and_the_password_is(String user, String pass) { // Write code here that turns the phrase above into concrete actions // throw new io.cucumber.java.PendingException(); - L.set_username(user); L.set_password(pass); + L.setUsername(user); L.setPassword(pass); } @@ -23,7 +22,7 @@ public void the_username_is_and_the_password_is(String user, String pass) { public void i_fill_in_the_username(String entered_user) { // Write code here that turns the phrase above into concrete actions //throw new io.cucumber.java.PendingException(); - L.entered_username = entered_user; + L.setEnteredUsername(entered_user); } @@ -31,7 +30,7 @@ public void i_fill_in_the_username(String entered_user) { public void i_fill_in_the_password(String entered_pass) { // Write code here that turns the phrase above into concrete actions //throw new io.cucumber.java.PendingException(); - L.entered_passsword = entered_pass; + L.setEnteredPasssword(entered_pass); } @@ -39,7 +38,7 @@ public void i_fill_in_the_password(String entered_pass) { public void the_user_should_be_logged_in() { // Write code here that turns the phrase above into concrete actions // throw new io.cucumber.java.PendingException(); - assertTrue((L.entered_username.equals(L.username)) && (L.entered_passsword.equals(L.password))); + assertTrue((L.getEnteredUsername().equals(L.getUsername())) && (L.getEnteredPasssword().equals(L.getPassword()))); } @@ -48,7 +47,7 @@ public void the_user_should_be_logged_in() { public void the_user_should_not_be_logged_in() { // Write code here that turns the phrase above into concrete actions // throw new io.cucumber.java.PendingException(); - assertTrue((L.entered_username.equals(L.username)) && !(L.entered_passsword.equals(L.password))); + assertTrue((L.getEnteredUsername().equals(L.getUsername())) && !(L.getEnteredPasssword().equals(L.getPassword()))); } diff --git a/src/test/java/Test_Package/LogoutSteps.java b/src/test/java/Test_Package/LogoutSteps.java index 94150f4..c9dbbc9 100644 --- a/src/test/java/Test_Package/LogoutSteps.java +++ b/src/test/java/Test_Package/LogoutSteps.java @@ -3,11 +3,11 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import Main_Package.logout; +import mainpackage.Logout; import static org.junit.Assert.assertTrue; public class LogoutSteps { - logout X = new logout(); + Logout X = new Logout(); @Given("the user is logged in") public void the_user_is_logged_in() { // Write code here that turns the phrase above into concrete actions @@ -26,8 +26,8 @@ public void the_user_press_logout() { public void the_user_should_be_logged_out() { // Write code here that turns the phrase above into concrete actions // throw new io.cucumber.java.PendingException(); - assertTrue(logout.loggedout == true); - logout.loggedout = false; + assertTrue(X.getLoggedout()); + X.setLoggedout(false); } } diff --git a/src/test/java/Test_Package/SearchSteps.java b/src/test/java/Test_Package/SearchSteps.java index bbc24b5..e9f0733 100644 --- a/src/test/java/Test_Package/SearchSteps.java +++ b/src/test/java/Test_Package/SearchSteps.java @@ -2,8 +2,8 @@ import static org.junit.Assert.assertTrue; -import Main_Package.Book; -import Main_Package.Books_Library; +import mainpackage.Book; +import mainpackage.BooksLibrary; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; @@ -27,7 +27,7 @@ public void user_enters_substring_of_valid_title(String string) div=string.length(); - for (Book book:Books_Library.Books) + for (Book book: BooksLibrary.books2) { if (book.getTitle().length()>=div) { @@ -43,14 +43,14 @@ public void show_book_information_for_books_with_title(String string) { if (found==false) { - assertTrue(found==false); + assertTrue(!found); System.out.println("No book found with such "+'"'+string+'"'); } else { - assertTrue(found==true); + assertTrue(found); div=string.length(); - for (Book book:Books_Library.Books) + for (Book book: BooksLibrary.books2) { if (book.getTitle().length()>=div) { @@ -69,7 +69,7 @@ public void user_enters_substring_of_valid_author(String string) div=string.length(); - for (Book book:Books_Library.Books) + for (Book book: BooksLibrary.books2) { if (book.getAuthor().length()>=div) { @@ -85,14 +85,14 @@ public void show_book_information_for_books_with_author(String string) { if (found==false) { - assertTrue(found==false); + assertTrue(!found); System.out.println("No book found with such "+'"'+string+'"'); } else { - assertTrue(found==true); + assertTrue(found); div=string.length(); - for (Book book:Books_Library.Books) + for (Book book: BooksLibrary.books2) { if (book.getAuthor().length()>=div) { @@ -110,7 +110,7 @@ public void user_enters_substring_of_valid_isbn(String string) System.out.printf("----------- %s ----------- %n" , string ); div=string.length(); - for (Book book:Books_Library.Books) + for (Book book: BooksLibrary.books2) { if (book.getISBN().length()>=div) { @@ -127,14 +127,14 @@ public void show_book_information_for_books_with_isbn(String string) { if (found==false) { - assertTrue(found==false); + assertTrue(!found); System.out.println("No book found with such "+'"'+string+'"'); } else { - assertTrue(found==true); + assertTrue(found); div=string.length(); - for (Book book:Books_Library.Books) + for (Book book: BooksLibrary.books2) { if (book.getISBN().length()>=div) { diff --git a/target/classes/Main_Package/Books_Library.class b/target/classes/Main_Package/Books_Library.class deleted file mode 100644 index 8dfffba..0000000 Binary files a/target/classes/Main_Package/Books_Library.class and /dev/null differ diff --git a/target/classes/Main_Package/login.class b/target/classes/Main_Package/login.class deleted file mode 100644 index 66b27ff..0000000 Binary files a/target/classes/Main_Package/login.class and /dev/null differ diff --git a/target/classes/Main_Package/logout.class b/target/classes/Main_Package/logout.class deleted file mode 100644 index b88f5ca..0000000 Binary files a/target/classes/Main_Package/logout.class and /dev/null differ diff --git a/target/test-classes/Test_Package/AddBookSteps.class b/target/test-classes/Test_Package/AddBookSteps.class index 40d9091..274a57a 100644 Binary files a/target/test-classes/Test_Package/AddBookSteps.class and b/target/test-classes/Test_Package/AddBookSteps.class differ diff --git a/target/test-classes/Test_Package/Config.class b/target/test-classes/Test_Package/Config.class index 25ea38a..d694f60 100644 Binary files a/target/test-classes/Test_Package/Config.class and b/target/test-classes/Test_Package/Config.class differ diff --git a/target/test-classes/Test_Package/LoginSteps.class b/target/test-classes/Test_Package/LoginSteps.class index 467b6de..f086bbf 100644 Binary files a/target/test-classes/Test_Package/LoginSteps.class and b/target/test-classes/Test_Package/LoginSteps.class differ diff --git a/target/test-classes/Test_Package/LogoutSteps.class b/target/test-classes/Test_Package/LogoutSteps.class index 563d591..0f7e510 100644 Binary files a/target/test-classes/Test_Package/LogoutSteps.class and b/target/test-classes/Test_Package/LogoutSteps.class differ