Search in sources :

Example 6 with JsonTransferer

use of nl.tudelft.watchdog.core.logic.network.JsonTransferer in project watchdog by TestRoots.

the class UserRegistrationStep method makeRegistration.

protected void makeRegistration() {
    User user = new User();
    user.email = getEmailInput().getText();
    user.organization = getOrganizationInput().getText();
    user.mayContactUser = getMayContactUser();
    user.programmingExperience = getProgrammingExperience();
    user.operatingSystem = System.getProperty("os.name");
    try {
        id = new JsonTransferer().registerNewUser(user);
    } catch (ServerCommunicationException exception) {
        successfulRegistration = false;
        messageTitle = "Problem creating new user!";
        messageBody = "<html>" + WordUtils.wrap(exception.getMessage(), 100, "<br>", true);
        messageBody += "<br>Are you connected to the internet, and is port 80 open?";
        messageBody += "<br>Please contact us via www.testroots.org. <br>We'll troubleshoot the issue!</html>";
        return;
    }
    successfulRegistration = true;
    ((UserProjectRegistrationWizard) getWizard()).userid = id;
    messageTitle = "New user registered!";
    messageBody = "Your new user id is registered: ";
    Preferences preferences = Preferences.getInstance();
    preferences.setUserId(id);
    preferences.registerProjectId(WatchDogUtils.getProjectName(), "");
    preferences.setProgrammingExperience(user.programmingExperience);
}
Also used : JsonTransferer(nl.tudelft.watchdog.core.logic.network.JsonTransferer) ServerCommunicationException(nl.tudelft.watchdog.core.logic.network.ServerCommunicationException) User(nl.tudelft.watchdog.core.ui.wizards.User) Preferences(nl.tudelft.watchdog.intellij.ui.preferences.Preferences)

Example 7 with JsonTransferer

use of nl.tudelft.watchdog.core.logic.network.JsonTransferer in project watchdog by TestRoots.

the class ProjectCreatedEndingPage method makeRegistration.

@Override
protected void makeRegistration() {
    Project project = new Project(Preferences.getInstance().getUserId());
    ProjectSliderPage sliderPage;
    ProjectRegistrationPage projectPage = null;
    if (getPreviousPage() instanceof ProjectRegistrationPage) {
        projectPage = (ProjectRegistrationPage) getPreviousPage();
    } else if (getPreviousPage() instanceof ProjectSliderPage) {
        sliderPage = (ProjectSliderPage) getPreviousPage();
        projectPage = (ProjectRegistrationPage) getPreviousPage().getPreviousPage();
        project.productionPercentage = sliderPage.percentageProductionSlider.getSelection();
        project.useJunitOnlyForUnitTesting = sliderPage.usesJunitForUnitTestingOnly();
        project.followTestDrivenDesign = sliderPage.usesTestDrivenDesing();
    }
    if (projectPage == null) {
        messageTitle = "How did you get here?";
        messageBody = "We couldn't figure out which wizard page\n";
        messageBody += "you came from. Please restart the registration.";
        WatchDogLogger.getInstance().logSevere("Unknown previous page");
        return;
    }
    // initialize from projectPage
    project.belongToASingleSoftware = !projectPage.noSingleProjectButton.getSelection();
    project.name = projectPage.projectNameInput.getText();
    project.website = projectPage.projectWebsite.getText();
    project.usesContinuousIntegration = projectPage.usesContinuousIntegration();
    project.usesJunit = projectPage.usesJunit();
    project.usesOtherTestingFrameworks = projectPage.usesOtherTestingFrameworks();
    project.usesOtherTestingForms = projectPage.usesOtherTestingForms();
    windowTitle = "Registration Summary";
    try {
        id = new JsonTransferer().registerNewProject(project);
    } catch (ServerCommunicationException exception) {
        successfulRegistration = false;
        messageTitle = "Problem creating new project!";
        messageBody = WordUtils.wrap(exception.getMessage(), 100, null, true);
        messageBody += "\nAre you connected to the internet, and is port 80 open?";
        messageBody += "\nPlease contact us via www.testroots.org. \nWe'll troubleshoot the issue!";
        WatchDogLogger.getInstance().logSevere(exception);
        return;
    }
    successfulRegistration = true;
    ((RegistrationWizardBase) getWizard()).setProjectId(id);
    messageTitle = "New project registered!";
    messageBody = "Your new project id is registered: ";
}
Also used : JsonTransferer(nl.tudelft.watchdog.core.logic.network.JsonTransferer) ServerCommunicationException(nl.tudelft.watchdog.core.logic.network.ServerCommunicationException) Project(nl.tudelft.watchdog.core.ui.wizards.Project) RegistrationWizardBase(nl.tudelft.watchdog.eclipse.ui.wizards.RegistrationWizardBase)

Example 8 with JsonTransferer

use of nl.tudelft.watchdog.core.logic.network.JsonTransferer in project watchdog by TestRoots.

the class NetworkUtilsTest method testIntervalTransfer.

@Test
@Ignore
public void testIntervalTransfer() {
    JsonTransferer it = new JsonTransferer();
    IntervalBase interval = new IDEOpenInterval(new Date());
    ArrayList<WatchDogItem> intervals = createSampleIntervals(interval);
    String json = it.toJson(intervals);
    try {
        NetworkUtils.transferJsonAndGetResponse(NetworkUtils.buildIntervalsPostURL(fooBarUser, fooBarProject), json);
    } catch (ServerCommunicationException | ServerReturnCodeException e) {
        fail(e.getMessage());
    }
}
Also used : JsonTransferer(nl.tudelft.watchdog.core.logic.network.JsonTransferer) ServerCommunicationException(nl.tudelft.watchdog.core.logic.network.ServerCommunicationException) IntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase) ServerReturnCodeException(nl.tudelft.watchdog.core.logic.network.ServerReturnCodeException) IDEOpenInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval) Date(java.util.Date) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

JsonTransferer (nl.tudelft.watchdog.core.logic.network.JsonTransferer)8 ServerCommunicationException (nl.tudelft.watchdog.core.logic.network.ServerCommunicationException)8 User (nl.tudelft.watchdog.core.ui.wizards.User)4 Preferences (nl.tudelft.watchdog.intellij.ui.preferences.Preferences)3 Project (nl.tudelft.watchdog.core.ui.wizards.Project)2 Project (com.intellij.openapi.project.Project)1 Date (java.util.Date)1 IDEOpenInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval)1 IntervalBase (nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase)1 ServerReturnCodeException (nl.tudelft.watchdog.core.logic.network.ServerReturnCodeException)1 WatchDogItem (nl.tudelft.watchdog.core.logic.storage.WatchDogItem)1 Preferences (nl.tudelft.watchdog.eclipse.ui.preferences.Preferences)1 RegistrationWizardBase (nl.tudelft.watchdog.eclipse.ui.wizards.RegistrationWizardBase)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1