Search in sources :

Example 11 with Bid

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);
}
Also used : AddBidRequest(com.cmput301w18t05.taskzilla.request.command.AddBidRequest)

Example 12 with Bid

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);
    }
}
Also used : RemoveBidRequest(com.cmput301w18t05.taskzilla.request.command.RemoveBidRequest) GetBidsByTaskIdRequest(com.cmput301w18t05.taskzilla.request.command.GetBidsByTaskIdRequest)

Example 13 with Bid

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());
}
Also used : GetTaskRequest(com.cmput301w18t05.taskzilla.request.command.GetTaskRequest) DecimalFormat(java.text.DecimalFormat)

Example 14 with Bid

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"));
}
Also used : MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity) View(android.view.View)

Example 15 with Bid

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);
}
Also used : AddTaskRequest(com.cmput301w18t05.taskzilla.request.command.AddTaskRequest) AddUserRequest(com.cmput301w18t05.taskzilla.request.command.AddUserRequest)

Aggregations

View (android.view.View)7 Bid (com.cmput301w18t05.taskzilla.Bid)5 AlertDialog (android.support.v7.app.AlertDialog)4 AdapterView (android.widget.AdapterView)4 ListView (android.widget.ListView)4 TextView (android.widget.TextView)4 DecimalFormat (java.text.DecimalFormat)4 RecyclerView (android.support.v7.widget.RecyclerView)3 Button (android.widget.Button)3 ExpandableListView (android.widget.ExpandableListView)3 ImageButton (android.widget.ImageButton)3 ScrollView (android.widget.ScrollView)3 GetUserRequest (com.cmput301w18t05.taskzilla.request.command.GetUserRequest)3 RemoveBidRequest (com.cmput301w18t05.taskzilla.request.command.RemoveBidRequest)3 ArrayAdapter (android.widget.ArrayAdapter)2 Task (com.cmput301w18t05.taskzilla.Task)2 User (com.cmput301w18t05.taskzilla.User)2 MainActivity (com.cmput301w18t05.taskzilla.activity.MainActivity)2 ProfileController (com.cmput301w18t05.taskzilla.controller.ProfileController)2 com.cmput301w18t05.taskzilla.currentUser (com.cmput301w18t05.taskzilla.currentUser)2