Before You Begin
Purpose
In this tutorial, you will learn how to perform code reviews using Oracle Developer Cloud Service and NetBeans IDE.
Time to Complete
Approximately 30 minutes
Introduction
The Merge Requests component of Oracle Developer Cloud Service allows you to do the following:
- Create code reviews and assign them to members of your team
- As a team member, complete an assigned code review
Scenario
You have been assigned a task to add a Java web service to a project. You'll need to create a merge request along with a Git repository branch to make the code change. Then you'll get your code change reviewed by a team member. Once it has been reviewed, you will merge the changes from the branch back to the master.
In the environment you are using for this tutorial, you may be the only team member. For this reason, you'll submit the code changes for review and then perform the review yourself.
Context
The work you do for this tutorial would normally be done as part of an assigned issue. See the OBE tutorial Managing Issues Using Oracle Developer Cloud Service for information about working on issues.
The Oracle JDeveloper Team Server works very similarly to the NetBeans IDE Team Server. You can complete the Team Server tasks using Oracle JDeveloper.
What Do You Need?
-
A login to an Oracle Developer Cloud Service instance
-
One of the following supported browsers:
- Chrome 48 or later (also for Android)
- Firefox 38 or later
- Internet Explorer 11 or 12
- Safari 7 or 8 (Mac OS)
- Safari Mobile 5 (iOS)
-
An installation of NetBeans IDE with the Oracle Developer Cloud Service plugin. See "Using NetBeans IDE with Oracle Developer Cloud Service" in Using Oracle Developer Cloud Service.
-
Some experience developing applications in Java
-
Some familiarity with the Git source control system
-
Some familiarity with NetBeans IDE
It would be helpful if you first completed the OBE tutorials Using NetBeans IDE to Create an Oracle Developer Cloud Service Project and Managing Issues Using Oracle Developer Cloud Service. This tutorial uses the project created in the first tutorial, but you can use any project to which you have access.
Creating a Merge Request and Branch
-
If you are not already logged in, launch your Oracle Developer Cloud Service, following the instructions in "Accessing Oracle Developer Cloud Service Using the Web Interface" in Using Oracle Developer Cloud Service. When you reach the Welcome page, click your project, which in this case is My Web Application.
Description of this image The project Home page opens.
-
From the project Home page, click the Merge Requests tab to see the results of the default Created By Me standard search.
Description of this image -
Click the New Merge Request button on the right to open the New Merge Request wizard.
Description of this image -
On the Branch page of the wizard, from the Repository drop-down list, select my-web-application.git.
From the Target Branch drop-down list, select master.
In the Review Branch drop-down list, enter
SvcBranch
to create a branch for the review. This field presents you with a list of branches if there are any, but you can also use it to create a branch if a branch of that name does not exist.Click Next.
Description of this image -
On the Details page of the wizard, Leave the Linked Issues and Linked Builds fields empty.
In the Summary field, enter a title for the review, such as
Review Web Service
.In the Reviewers field, select your own name. (Normally, you would assign the review to one or more members of your team.)
Click Next.
Description of this image -
On the Description page of the wizard, in the Edit Description text area, enter a message such as
Please review the new web service
.Finally, click Create.
Description of this image The review opens in a page of its own with the following tabs: Conversation, Commits, Changed Files, Linked Issues, and Linked Builds.
Description of this image On the right side are buttons for the reviewer to use: Merge, Approve, Reject, and Close. Below the buttons are a list of reviewers and a list of linked builds.
Description of this image -
Click the Code tab and view the files in the master.
Description of this image -
Select SvcBranch from the branch drop-down list.
Description of this image -
Verify that the files in the branch are the same as those in the master.
Description of this image
Creating the New Branch in NetBeans IDE
These steps assume that you previously established a connection from NetBeans IDE to your Oracle Developer Cloud Service instance by following the instructions in the OBE tutorial Using NetBeans IDE to Create an Oracle Developer Cloud Service Project.
The Oracle JDeveloper Team Server works very similarly to the NetBeans IDE Team Server. You can complete the Team Server tasks using Oracle JDeveloper.
-
Launch NetBeans IDE if it is not already open. Click the Projects tab, right-click MyWebApp. From the menu, select Git, then select Remote, and then select Fetch.
Description of this image -
On the Remote Repository page of the Fetch from Remote Repository wizard, click Next.
Description of this image -
On the Remote Branches page, select the SvcBranch -> origin/SvcBranch check box and click Finish.
Description of this image -
Right-click the project and select Git, then select Branch/Tag, and then select Create Branch.
Description of this image - In the Create Branch dialog box, enter
SvcBranch
in the Branch Name field. Verify that the Revision value ismaster
. Then select the Checkout Created Branch check box and click Create. -
Return to the Projects tab, right-click the project, and select Git, then select Branch/Tag, and then select Set Tracked Branch.
Description of this image -
In the Select Branch dialog box, select origin/SvcBranch and click OK.
Description of this image -
From the Team menu, select Repository, and then select Repository Browser to open the repository browser if it is not already open.
Description of this image Verify that the local branch and master are tracking the remote branch and master, and that you are currently in the local branch (shown in bold).
Description of this image

Making Code Changes
-
In NetBeans IDE, right-click the project and select New, and then select Web Service. (The Web Service menu item can appear anywhere in the menu.)
Description of this image -
On the Name and Location page of the wizard, enter a name for the web service (
MyService
, for example) in the Web Service Name field. In the Package field, enterservice
. Finally, click Finish.Description of this image The service is created, and the source file
MyService.java
appears in the Source Packages area.Description of this image The source file also opens in an editor pane.
Description of this image -
NetBeans IDE shows a yellow warning icon next to the
hello
method. Click the icon and make the suggested changes to add@Param
and@Return
annotations to the Javadoc comments, then save the file.Description of this image -
Right-click your project and select Git, and then select Commit.
Description of this image -
In the MyWebApp - SvcBranch commit dialog box, enter
Added web service
in the Commit Message text area, making sure that theMyService.java
file is being added. Some other NetBeans IDE files may be added and modified as well. Then click Commit.Description of this image -
Right-click your project and select Git, then select Remote, and then select Push to Upstream.
Description of this image The commit contents are pushed to the remote branch.
Verifying the Push in Oracle Developer Cloud Service
-
In the browser, click the Project tab and verify that the push you made appears in the activity feed.
Description of this image -
Click Code, then click Commits. Select master from the branch drop-down list if it is not already selected, and view the commits to the master.
Description of this image -
From the branch drop-down list, select SvcBranch.
Description of this image The new commit is displayed along with the previous ones.
Description of this image -
To verify that the new service was committed, click Show Details on the right side of the commit.
Description of this image The commit details are displayed.
Description of this image
Performing a Review
-
Click the Merge Requests tab to go to to the Merge Requests page. With the default Created By Me standard search selected, the Merge Requests table shows the review you assigned to yourself, with the status OPEN. (This review also appears for all the standard searches except All Closed Requests.) Click the Review Web Service Summary link to go to the review page.
Description of this image The review page displays the actions related to the review: conversations, commits, file changes, linked issues, linked builds, and buttons for possible actions you might take. It now shows the commit to the branch.
Description of this image -
To review the code changes, click the Changed Files tab. You will see the new Java source file along with any other added or modified files. The changes have a green or pink background to indicate code additions and deletions.
Description of this image -
Scroll down to the source file
MyService.java
and mouse over the line numbers to the left of the code. A plus sign is displayed to indicate that you can add a comment. Click the plus (+) sign.Description of this image -
Enter a comment in the comment pane.
Description of this image -
Click the Comment button to add the comment to the code. (The Save button puts the comment in a Pending Comments tab for later publication.)
Description of this image The comment appears in the code.
Description of this image -
Click Approve to approve the changes.
Description of this image -
In the dialog box that is displayed, add a comment (for example,
Looks fine so far
), and then click OK.Description of this image The approval appears on the right side of the page.
Description of this image -
Click the Conversation tab. The comment and approval also appear in the Conversation area.
Description of this image You could also post a general comment at the bottom of the page, using your chosen Wiki markup language.
Description of this image
You have now completed your role as a reviewer. Since you are the only reviewer, the submitter (also you) can now consider the review complete.
Merging the Code
-
Click the Back to Merge Request List icon (<) or the Merge Requests tab to return to the Merge Requests page. In the Merge Requests table, the Status column still shows the review as OPEN. Either the submitter or a reviewer can perform the merge.
Click the review link to go to the review page.
Description of this image Note: By default, a submitter or reviewer can merge a branch or close a review, whether or not code changes have been approved by reviewers. Approving or rejecting a merge request is just a special way to add a comment that you approve or disapprove the changes made to the source code.
-
On the review page, click Merge.
Description of this image -
In the Merge dialog box, add a comment (
Merging new web service after review
, for example). Select the Squash commits check box, but do not select the Delete branch check box. Finally, click Merge.Description of this image The review status is shown as MERGED.
Description of this image -
Click the Merge Requests tab. The completed review appears in the Merge Requests table for the Created By Me, All Closed Requests, and All Requests standard searches, with the status MERGED.
Description of this image -
Click the Project tab. The main review actions appear in the activity feed.
Description of this image -
Click Code and look at the comment on the SvcBranch branch.
Description of this image -
In the branch drop-down list, select master.
Description of this image View the comment on the master. The merge comment appears on the master.
Description of this image
Now you can pull the changes down to your local repository using NetBeans IDE.
Pulling the Changes to Your Local Repository
-
In NetBeans IDE, log in to the Team Server. From the Team menu, select Team Server, and then select Login. Click Login in the Login to Team Server dialog box.
Description of this image -
Click the Projects tab. Right-click the MyWebApp project and select Git, then select Remote, and then select Pull.
Description of this image -
On the Remote Repository page of the Pull from Remote Repository wizard, click Next.
Description of this image -
On the Remote Branches page, select both check boxes, and then click Finish.
Description of this image The local branch is updated with any changes from the remote one. In the Repository Browser, though, the local master is behind origin/master.
Description of this image -
Now, pull the changes to the local master. Right-click the project and select Git, then select Branch/Tag, and then select Switch to Branch.
Description of this image -
In the Switch to Selected Branch dialog box, select master, and then click Switch.
Description of this image -
The project does not currently contain the new web service. Right-click the project and select Git, then select Remote, and then select Pull.
Description of this image -
On the Remote Repository page of the Pull from Remote Repository dialog box, click Next.
Description of this image -
On the Remote Branches page, verify that the master -> origin/master check box is selected, and then click Finish.
Description of this image The new web service code now appears in the project.
Description of this image In the Repository Browser, the local and remote master are now in sync.
Description of this image If you wish, you can now return to the browser and delete the branch from the merge request.
Want to Learn More?
- Using NetBeans IDE to Create an Oracle Developer Cloud Service Project OBE
- Managing Issues Using Oracle Developer Cloud Service OBE
- Oracle Developer Cloud Service in the Oracle Help Center
- Using Oracle Developer Cloud Service in the Oracle Help Center
- Oracle Developer Cloud Service product page