-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1ea2d9
commit 32776a8
Showing
33 changed files
with
1,214 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
Dashboard/JUnitMockitoHandsOns/Electricity Bill/ElectricityBill/src/EBBill.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
import java.util.Scanner; | ||
|
||
public class EBBill { | ||
private int units; | ||
|
||
public EBBill(int units) { | ||
this.units = units; | ||
} | ||
|
||
public double calculateBillAmount() { | ||
double amount=0.0; | ||
|
||
if (units > 0) { | ||
if (units <= 50) | ||
amount = units * 2.60; | ||
else if (units <= 100) | ||
amount = 130 + ((units - 50) * 3.25); | ||
else if (units <= 200) | ||
amount = 130 + 162.50 + ((units - 100 ) * 5.26); | ||
else if (units <= 1000) | ||
amount = 130 + 162.50 + 526 + ((units - 200 ) * 7.75); | ||
else if (units <= 5000) | ||
amount = 130 + 162.50 + 526 + 6200 + ((units - 1000) * 10); | ||
else | ||
amount = 0.0; | ||
} | ||
return amount; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
Dashboard/JUnitMockitoHandsOns/Electricity Bill/ElectricityBill/src/EBBillTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import static org.junit.Assert.assertEquals; | ||
import org.junit.Test; | ||
|
||
|
||
public class EBBillTest { | ||
//Write JUNIT Test Code | ||
|
||
EBBill bill = null; | ||
|
||
@Test | ||
public void testCalculateBillAmount_Input_0() { | ||
bill = new EBBill(0); | ||
assertEquals(0, bill.calculateBillAmount(), 0.001); | ||
} | ||
|
||
@Test | ||
public void testCalculateBillAmount_Input_50() { | ||
bill = new EBBill(50); | ||
assertEquals(130, bill.calculateBillAmount(), 0.001); | ||
} | ||
|
||
@Test | ||
public void testCalculateBillAmount_Input_100() { | ||
bill = new EBBill(100); | ||
assertEquals(292.5, bill.calculateBillAmount(), 0.001); | ||
} | ||
|
||
@Test | ||
public void testCalculateBillAmount_Input_200() { | ||
bill = new EBBill(200); | ||
assertEquals(818.5, bill.calculateBillAmount(), 0.001); | ||
} | ||
|
||
@Test | ||
public void testCalculateBillAmount_Input_1000() { | ||
bill = new EBBill(1000); | ||
assertEquals(7018.5, bill.calculateBillAmount(), 0.001); | ||
} | ||
|
||
@Test | ||
public void testCalculateBillAmount_Input_5000() { | ||
bill = new EBBill(5000); | ||
assertEquals(47018.5, bill.calculateBillAmount(), 0.001); | ||
} | ||
|
||
} | ||
|
20 changes: 20 additions & 0 deletions
20
Dashboard/JUnitMockitoHandsOns/Electricity Bill/ElectricityBill/src/UserInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import org.junit.runner.JUnitCore; | ||
import org.junit.runner.Result; | ||
import org.junit.runner.notification.Failure; | ||
|
||
public class UserInterface | ||
{ | ||
public static void main(String args[]) | ||
{ | ||
Result result = JUnitCore.runClasses(EBBillTest.class); | ||
|
||
if (result.getFailureCount() == 0) | ||
System.out.println("There are No Failures...\n Test Passed..."); | ||
else { | ||
for(Failure failure: result.getFailures()) { | ||
System.out.println("The Test execution failed...\n" + failure.getMessage()); | ||
} | ||
} | ||
System.out.println("Result" + result.wasSuccessful()); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Dashboard/JUnitMockitoHandsOns/Hands On - LMS Refactoring/LMS/src/library/Book.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package library; | ||
|
||
public class Book { | ||
private final String bookId; | ||
private final String bookTitle; | ||
private final String authorName; | ||
private final String publisherName; | ||
|
||
public String getBookId() { | ||
return bookId; | ||
} | ||
public String getBookTitle() { | ||
return bookTitle; | ||
} | ||
public String getAuthorName() { | ||
return authorName; | ||
} | ||
public String getPublisherName() { | ||
return publisherName; | ||
} | ||
|
||
public Book(String bookId, String bookTitle, String authorName, String publisherName) { | ||
super(); | ||
this.bookId = bookId; | ||
this.bookTitle = bookTitle; | ||
this.authorName = authorName; | ||
this.publisherName = publisherName; | ||
} | ||
|
||
|
||
} |
29 changes: 29 additions & 0 deletions
29
Dashboard/JUnitMockitoHandsOns/Hands On - LMS Refactoring/LMS/src/library/BookDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package library; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class BookDAO { | ||
|
||
ArrayList<Book> l = new ArrayList<Book>(); | ||
|
||
public void addBook(Book obj){ | ||
l.add(obj); | ||
} | ||
|
||
public void removeBook(Book obj) | ||
{ | ||
l.remove(obj); | ||
} | ||
|
||
public void viewBookDAO() | ||
{ | ||
for(int i=0;i<l.size();i++) | ||
{ | ||
System.out.println("Book Id:" + l.get(i).getBookId()); | ||
System.out.println("Book Title:" + l.get(i).getBookTitle()); | ||
System.out.println("Author Name:" + l.get(i).getAuthorName()); | ||
System.out.println("Publisher Name:" + l.get(i).getPublisherName()); | ||
|
||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
Dashboard/JUnitMockitoHandsOns/Hands On - LMS Refactoring/LMS/src/library/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package library; | ||
|
||
public class Member { | ||
private final String memberId; | ||
private final String memberName; | ||
private final String memberType; | ||
private final int entitlement; | ||
private final String address; | ||
private final String emailId; | ||
|
||
|
||
public Member(String memberId, String memberName, String memberType, int entitlement, String address, | ||
String emailId) { | ||
super(); | ||
this.memberId = memberId; | ||
this.memberName = memberName; | ||
this.memberType = memberType; | ||
this.entitlement = entitlement; | ||
this.address = address; | ||
this.emailId = emailId; | ||
} | ||
public String getMemberId() { | ||
return memberId; | ||
} | ||
public String getMemberName() { | ||
return memberName; | ||
} | ||
public String getMemberType() { | ||
return memberType; | ||
} | ||
public int getEntitlement() { | ||
return entitlement; | ||
} | ||
public String getAddress() { | ||
return address; | ||
} | ||
public String getEmailId() { | ||
return emailId; | ||
} | ||
public String toString(){ | ||
return memberId + " " + memberName; | ||
} | ||
} | ||
|
||
|
||
|
32 changes: 32 additions & 0 deletions
32
Dashboard/JUnitMockitoHandsOns/Hands On - LMS Refactoring/LMS/src/library/MemberDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package library; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class MemberDAO { | ||
ArrayList<Member> memberList = new ArrayList<Member>(); | ||
|
||
public void addMember(Member obj){ | ||
memberList.add(obj); | ||
} | ||
|
||
public void removeMember(Member obj) | ||
{ | ||
memberList.remove(obj); | ||
} | ||
|
||
public void viewMember() | ||
{ | ||
for(int i=0;i<memberList.size();i++) | ||
{ | ||
System.out.println("Member Id:" + memberList.get(i).getMemberId()); | ||
System.out.println("Member Title:" + memberList.get(i).getMemberName()); | ||
System.out.println("Member Type:" + memberList.get(i).getMemberType()); | ||
System.out.println("Address:" + memberList.get(i).getAddress()); | ||
System.out.println("Email-id:" + memberList.get(i).getEmailId()); | ||
System.out.println("Entitlement:" + memberList.get(i).getEntitlement()); | ||
|
||
|
||
} | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
Dashboard/JUnitMockitoHandsOns/Hands On - LMS Refactoring/LMS/src/library/Transaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package library; | ||
|
||
import java.util.Date; | ||
|
||
public class Transaction { | ||
private final Member member; | ||
private final Book book; | ||
private final int transactionId; | ||
private final String transactionType; | ||
private static final int NO_OF_BOOKS = 0; | ||
private final Date transactionDate; | ||
private final Date bookTobeReturnDate; | ||
private final Date bookReturnDate; | ||
private final double penalty; | ||
|
||
public Transaction(Member member, Book book, int transactionId, String transactionType, Date transactionDate, | ||
Date bookTobeReturnDate, Date bookReturnDate, double penalty) { | ||
super(); | ||
this.member = member; | ||
this.book = book; | ||
this.transactionId = transactionId; | ||
this.transactionType = transactionType; | ||
this.transactionDate = transactionDate; | ||
this.bookTobeReturnDate = bookTobeReturnDate; | ||
this.bookReturnDate = bookReturnDate; | ||
this.penalty = penalty; | ||
} | ||
public Member getMember() { | ||
return member; | ||
} | ||
public Book getBook() { | ||
return book; | ||
} | ||
public int getTransactionId() { | ||
return transactionId; | ||
} | ||
public String getTransactionType() { | ||
return transactionType; | ||
} | ||
public static int getNoOfBooks() { | ||
return NO_OF_BOOKS; | ||
} | ||
public Date getTransactionDate() { | ||
return transactionDate; | ||
} | ||
public Date getBookTobeReturnDate() { | ||
return bookTobeReturnDate; | ||
} | ||
public Date getBookReturnDate() { | ||
return bookReturnDate; | ||
} | ||
public double getPenalty() { | ||
return penalty; | ||
} | ||
|
||
} | ||
|
35 changes: 35 additions & 0 deletions
35
...board/JUnitMockitoHandsOns/Hands On - LMS Refactoring/LMS/src/library/TransactionDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package library; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class TransactionDAO { | ||
ArrayList<Transaction> transactionList = new ArrayList<Transaction>(); | ||
|
||
public void addTransaction(Transaction obj){ | ||
transactionList.add(obj); | ||
} | ||
|
||
public void removeTransaction(Transaction obj) | ||
{ | ||
transactionList.remove(obj); | ||
} | ||
|
||
public void viewTransaction(){ | ||
if(transactionList.isEmpty()){ | ||
System.out.println("Transaction List is empty"); | ||
} | ||
|
||
for (int i = 0; i < transactionList.size(); i++) { | ||
System.out.println("Transaction Id:" + transactionList.get(i).getTransactionId()); | ||
System.out.println("Member Id:"+transactionList.get(i).getMember().getMemberId()); | ||
System.out.println("Book Id:"+transactionList.get(i).getBook().getBookId()); | ||
System.out.println("Transaction Date:" + transactionList.get(i).getTransactionDate()); | ||
System.out.println("Transaction Type:"+transactionList.get(i).getTransactionType()); | ||
System.out.println("No Of Books:"+transactionList.get(i).getNoOfBooks()); | ||
System.out.println("Book Return Date:"+transactionList.get(i).getBookReturnDate()); | ||
} | ||
|
||
} | ||
|
||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...ized/RainbowJewellersParameterizedTest/src/com/cts/rainbowjewellers/RainbowJewellers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.cts.rainbowjewellers; | ||
|
||
import java.util.Scanner; | ||
|
||
import com.cts.rainbowjewellers.service.RainbowJewellersService; | ||
import com.cts.skeletonvalidator.SkeletonValidator; | ||
|
||
|
||
public class RainbowJewellers { | ||
|
||
public static void main(String[] args) { | ||
// CODE SKELETON - VALIDATION STARTS | ||
// DO NOT CHANGE THIS CODE | ||
SkeletonValidator validator = new SkeletonValidator(); | ||
// CODE SKELETON - VALIDATION ENDS | ||
|
||
Scanner scanner = new Scanner(System.in); | ||
|
||
System.out.println("Enter the gold in grams"); | ||
double grams = Double.parseDouble(scanner.nextLine()); | ||
|
||
RainbowJewellersService rainbowJewellersService = new RainbowJewellersService(); | ||
|
||
double totalPriceOfGold = rainbowJewellersService.calculategoldprice(grams); | ||
|
||
System.out.println("Total Price of the Gold is: " + totalPriceOfGold); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...ellersParameterizedTest/src/com/cts/rainbowjewellers/service/RainbowJewellersService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.cts.rainbowjewellers.service; | ||
|
||
public class RainbowJewellersService { | ||
|
||
private final double ratepergram = 4450.00; | ||
private double makingcharges; | ||
private double gst; | ||
private double totalprice; | ||
|
||
public double calculategoldprice(double gram) { | ||
double totalpriceofgold = 0.0d; | ||
totalprice = gram * ratepergram; | ||
makingcharges = (totalprice * 10) / 100; | ||
gst = (totalprice + makingcharges) * 3 / 100; | ||
totalpriceofgold = totalprice + makingcharges + gst; | ||
return totalpriceofgold; | ||
} | ||
|
||
public static void main(String args[]){ | ||
System.out.println(new RainbowJewellersService().calculategoldprice(20)); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.