use of com.cmput301w18t05.taskzilla.Bid in project Taskzilla by CMPUT301W18T05.
the class Task method addBid.
/**
* addBid
*
* @author praharen
*/
public void addBid(Bid newbid) {
System.out.println("Adding bid: " + newbid);
AddBidRequest addBidRequest = new AddBidRequest(newbid);
RequestManager.getInstance().invokeRequest(addBidRequest);
String temp = "Your task '" + this.getName() + "' has been bidded on by " + currentUser.getInstance().getUsername() + " for $" + newbid.getBidAmount();
Notification notification = new Notification("New Bid", newbid.getUserId(), this.getRequesterId(), this.Id, this.name, temp, currentUser.getInstance());
NotificationManager.getInstance().sendNotification(notification);
}
use of com.cmput301w18t05.taskzilla.Bid in project Taskzilla by CMPUT301W18T05.
the class Task method removeAllBids.
/**
* removeAllBids
* remove all bids under this task
* @author myapplestory
*/
private void removeAllBids() {
GetBidsByTaskIdRequest getbidrequest = new GetBidsByTaskIdRequest(this.Id);
RequestManager.getInstance().invokeRequest(getbidrequest);
ArrayList<Bid> bidlist = getbidrequest.getResult();
for (Bid bid : bidlist) {
RemoveBidRequest removerequest = new RemoveBidRequest(bid);
RequestManager.getInstance().invokeRequest(removerequest);
String temp = "Your bid has been declined!";
Notification notification = new Notification("Bid Declined", this.requesterId, this.providerId, this.Id, this.getName(), temp, currentUser.getInstance());
NotificationManager.getInstance().sendNotification(notification);
}
}
use of com.cmput301w18t05.taskzilla.Bid in project Taskzilla by CMPUT301W18T05.
the class Bid method toString.
/**
* Returns a string with the bid details
* @return the string which is with the details of the bid
*/
public String toString() {
GetTaskRequest taskRequest = new GetTaskRequest(this.taskId);
RequestManager.getInstance().invokeRequest(taskRequest);
DecimalFormat cents = new DecimalFormat("#0.00");
return "Task: " + taskRequest.getResult().getName() + " \nRequester: " + taskRequest.getResult().getTaskRequester().getName() + " \nStatus: " + taskRequest.getResult().getStatus() + "\nBid amount: $" + cents.format(this.bidAmount) + " Lowest bid: $" + cents.format(taskRequest.getResult().getBestBid());
}
use of com.cmput301w18t05.taskzilla.Bid in project Taskzilla by CMPUT301W18T05.
the class BidActivityIntentTest method testBid.
public void testBid() {
// Set up for Test
MainActivity activity = (MainActivity) solo.getCurrentActivity();
solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
solo.clickOnText("Sign Up");
solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
solo.enterText((EditText) solo.getView(R.id.usernameField), "TestUser");
solo.enterText((EditText) solo.getView(R.id.nameField), "TestName");
solo.enterText((EditText) solo.getView(R.id.passwordField), "a");
solo.enterText((EditText) solo.getView(R.id.emailField), "Test@Email.com");
solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
solo.clickOnButton("Sign Up");
// Correct Log in Info
solo.clearEditText((EditText) solo.getView(R.id.usernameText));
solo.enterText((EditText) solo.getView(R.id.usernameText), "TestUser");
solo.enterText((EditText) solo.getView(R.id.passwordText), "a");
solo.clickOnButton("Log In");
solo.waitForText("Tasks");
solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
solo.sleep(5000);
View fab = solo.getCurrentActivity().findViewById(R.id.fab);
solo.clickOnView(fab);
solo.waitForActivity(NewTaskActivity.class);
solo.assertCurrentActivity("Wrong Activity", NewTaskActivity.class);
// Valid Information
solo.clearEditText((EditText) solo.getView(R.id.Description));
solo.enterText((EditText) solo.getView(R.id.TaskName), "Test Task Name");
solo.clearEditText((EditText) solo.getView(R.id.Description));
solo.enterText((EditText) solo.getView(R.id.Description), "Test Description");
solo.clickOnButton("Add Task");
solo.waitForActivity(WelcomeActivity.class);
solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
solo.waitForText("Profile");
solo.clickOnText("Profile");
solo.clickOnText("Log out");
solo.waitForActivity(MainActivity.class);
solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
solo.clickOnText("Sign Up");
solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
solo.enterText((EditText) solo.getView(R.id.usernameField), "TestUserOne");
solo.enterText((EditText) solo.getView(R.id.nameField), "TestNameOne");
solo.enterText((EditText) solo.getView(R.id.passwordField), "a");
solo.enterText((EditText) solo.getView(R.id.emailField), "Test1@Email.com");
solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
solo.clickOnButton("Sign Up");
// Correct Log in Info
solo.clearEditText((EditText) solo.getView(R.id.usernameText));
solo.enterText((EditText) solo.getView(R.id.usernameText), "TestUserOne");
solo.enterText((EditText) solo.getView(R.id.passwordText), "a");
solo.clickOnButton("Log In");
solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
// Test Bid on task
solo.sleep(3000);
solo.waitForText("Search");
solo.clickOnText("Search");
solo.sleep(3000);
solo.waitForText("Status: ");
solo.clickOnText("Status: ");
solo.assertCurrentActivity("Wrong Activity", ViewTaskActivity.class);
solo.clickOnButton("PLACE BID");
solo.enterText((EditText) solo.getView(R.id.place_bid_edittext), "25.22");
solo.clickOnButton("Place Bid");
solo.sleep(1000);
solo.goBack();
// Test Bid in bid list
solo.waitForText("Bids");
solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
solo.clickOnText("Bids");
solo.waitForText("Bid amount: ");
solo.clickOnText("25.22");
solo.assertCurrentActivity("Wrong Activity", ViewTaskActivity.class);
// Test update bid
solo.sleep(500);
solo.waitForText("PLACE BID");
solo.clickOnButton("PLACE BID");
solo.enterText((EditText) solo.getView(R.id.place_bid_edittext), "29.22");
solo.clickOnButton("Place Bid");
solo.goBack();
solo.clickLongOnText("29.22");
// Test Delete bid
solo.sleep(2000);
assertTrue(solo.waitForText("29.22"));
}
use of com.cmput301w18t05.taskzilla.Bid in project Taskzilla by CMPUT301W18T05.
the class BidTest method testCompareTo.
/**
* Test for comparing a bid to another bid
* <p>
* greater than returns 1
* equality returns 0
* less than returns -1
*/
public void testCompareTo() {
User user1 = new User();
AddUserRequest addUserRequest = new AddUserRequest(user1);
RequestManager.getInstance().invokeRequest(getActivity(), addUserRequest);
Task task = new Task("Task name", user1, "Task description");
AddTaskRequest addTaskRequest = new AddTaskRequest(task);
RequestManager.getInstance().invokeRequest(getActivity(), addTaskRequest);
float bidAmount1 = 10.00f;
Bid bid1 = new Bid(user1.getId(), task.getId(), bidAmount1);
User user2 = new User();
AddUserRequest addUserRequest2 = new AddUserRequest(user2);
RequestManager.getInstance().invokeRequest(getActivity(), addUserRequest2);
float bidAmount2 = 1.00f;
Bid bid2 = new Bid(user2.getId(), task.getId(), bidAmount2);
assertEquals(bid1.compareTo(bid2), 1);
User user3 = new User();
AddUserRequest addUserRequest3 = new AddUserRequest(user3);
RequestManager.getInstance().invokeRequest(getActivity(), addUserRequest3);
float bidAmount3 = 10.00f;
Bid bid3 = new Bid(user3.getId(), task.getId(), bidAmount3);
assertEquals(bid1.compareTo(bid3), 0);
User user4 = new User();
AddUserRequest addUserRequest4 = new AddUserRequest(user4);
RequestManager.getInstance().invokeRequest(getActivity(), addUserRequest4);
float bidAmount4 = 20.00f;
Bid bid4 = new Bid(user4.getId(), task.getId(), bidAmount4);
assertEquals(bid1.compareTo(bid4), -1);
}
Aggregations