Brian Fraser
JUnit 4 with IntelliJ: A quick introduction
updated
My Videos on GSON
- GSON: Deserializing JSON under explicit control of Named fields: youtu.be/HSuVtkdej8Q
- GSON: Use IntelliJ: youtu.be/Qc9EfiepfWs
- GSON: Array or List as root of JSON: youtu.be/trCGXXNVVYE
- GSON: LocalDate Adapter: youtu.be/j2vWhohxBVA
My Videos on GSON
- GSON: Deserializing JSON under explicit control of Named fields: youtu.be/HSuVtkdej8Q
- GSON: Use IntelliJ: youtu.be/Qc9EfiepfWs
- GSON: Array or List as root of JSON: youtu.be/trCGXXNVVYE
- GSON: LocalDate Adapter: youtu.be/j2vWhohxBVA
My Videos on GSON
- GSON: Deserializing JSON under explicit control of Named fields: youtu.be/HSuVtkdej8Q
- GSON: Use IntelliJ: youtu.be/Qc9EfiepfWs
- GSON: Array or List as root of JSON: youtu.be/trCGXXNVVYE
- GSON: LocalDate Adapter: youtu.be/j2vWhohxBVA
- Joining a server
- Using text channels
- Having a text conversation
- Using voice calls
- Joining a voice channel
1. Launch Android Studio; create simple hello-world app.
2. See XML and .java code for activities
3. Add a button, change name, see XML
4. Java code to access button: View.OnClickListener
5. Generate a log message when button is clicked.
6. Generate a toast when button is clicked.
- Download VS Code: code.visualstudio.com/download
- Install WSL: docs.microsoft.com/en-us/windows/wsl/install
- MS GUide to Using C++ and WSL in VS Code: code.visualstudio.com/docs/cpp/config-wsl
References:
- smashingmagazine.com/2018/09/visual-studio-live
- docs.microsoft.com/en-us/visualstudio/liveshare/quickstart/share
1. setSupportActionBar() in onCreate()
2. Create now /res/menu/menu_xyz.xml
- setup any icons, IDs, and names in the xml
3. Show the menu via onCreateOptionsMenu()
4. Handle the menu clicks via onOptionsItemSelected()
5. Enable the left-arrow/back button (called 'up')
- in onCreate(): getSupportActionBar.setDisplayHomeAsUpEnabled(true);
- control its target via the manifest's android:parentActivityName property or
- control its action manually via android.R.id.home in onOptionsItemSelected()
- Install MinGW (G++ and GDB), configure paths
- Install VS Code
- Open a workspace for multiple activities (labs / assignments)
- Compile and run from within VS Code using the terminal
NOTE: Does not use F5 to run because under Windows it does not work well with cin!
- Install G++ and GDB
- Install VS Code
- Open a workspace for multiple activities (labs / assignments)
- Compile and run from within VS Code
[SOLUTION] Getting java.util.NoSuchElementException from a Scanner on System.in?
1. Expand the "Gradle Scripts" in your project view
2. Edit settings.gradle
3. Comment out (two //) the include ':app' line
Click Sync Now to resync your Gradle files
(This will change your project view; that's expected)
4. Re-run your program.
Note: If you use System.out.print() to print to the screen (note no linefeed) then it won't show up until after any pending System.in.nextXYZ() is finished.
Free Trial: bravurasoftware.com/optitune/free.aspx
Disclosure of interest: The lead developer on OptiTune is a friend. I was not paid or in any way compensated for making this video.
For creating JUnit 5 IntelliJ project, see youtu.be/o5pE7L2tVV8
Covers:
* basic asserts ( assertEquals(), assertTrue(), assertNotNull() ),
* @Test, @Disable,
* exceptions ( assertThrows() ), assertAll()
* timing ( assertTimeoutPreemptively() )
Disconnecting the cape is tricky, do it carefully!
Support videos via Patreon: patreon.com/DrBFraser
This 2018 video is a remake of an older video which featured an earlier version of Eclipse. It is part of a series of practical tutorials for using the EGit Eclipse plugin for working with a project using the Git revision control system. Demos use GitHub, but any remote repository would work.
Detail on Git, guide to command line interface: http://git-scm.com/book
Code on GitHub: github.com/drbfraser/SalesTool2018
Tutorial on EGit: docs.google.com/folder/d/0B4F_gjXVrHZVRXkydE0xVFBRRkc1WUpEcXdwQ2I1dw/edit?pli=1&docId=0B4F_gjXVrHZVc015aTNiNmhScktlcDJJTGNZd1NlQQ
1:15 Create local repo
2:30 Show Git toolbar / menu
4:30 Commit to local repo
7:35 Create GitHub repo and push
9:25 Configure Remotes (push references)
11:55 Force push to work round non-fast-forward: DANGEROUS!
13:00 Commit and push a change
14:30 Configure remote refecences and pull remote change
15:45 Navigator view to see all files
My guides to getting BeagleBone (Black/Green/...) working:
"Quick start": http://www.cs.sfu.ca/CourseCentral/433/bfraser/other/QuickStartGuide.pdf
List of guides: http://www.cs.sfu.ca/CourseCentral/433/bfraser/links.html
Embedded Linux device runs gdbserver, host runs gdb-multiarch. Commands demonstrated inculde:
- launching gdbserver and gdb-multiarch
- continue
- break
- info args
- next
My guides to getting BeagleBone (Black/Green/...) working:
"Quick start": http://www.cs.sfu.ca/CourseCentral/433/bfraser/other/QuickStartGuide.pdf
List of guides: http://www.cs.sfu.ca/CourseCentral/433/bfraser/links.html
Embedded Linux device runs gdbserver, host runs gdb-multiarch. Commands demonstrated inculde:
- launching gdbserver and gdb-multiarch
- continue
- break
- info args
- next
My guides to getting BeagleBone (Black/Green/...) working:
"Quick start": http://www.cs.sfu.ca/CourseCentral/433/bfraser/other/QuickStartGuide.pdf
List of guides: http://www.cs.sfu.ca/CourseCentral/433/bfraser/links.html
Full code: github.com/drbfraser/SpringBootIntro
(Including updated Gradle build script -- March 2020)
Covers creating a controller for a Rest API for GET and PUT requests, plus handling exceptions.
Full code: github.com/drbfraser/SpringBootIntro
(Including updated Gradle build script -- March 2020)
Covers what tools are needed (IntelliJ, Gradle), and how to create the project and test with curl.
1. New project "MyProjectName"
Create package
Create MyMain class with main()
2. Setup GSON object
File --- Project Structure
Libraries (on left)
Click the green +
Select "From Maven"
Enter: com/google/code/gson:gson:2.8.2
3. Basic main()
public static void main(String[] args) {
// Use GSON:
Gson gson = new Gson();
for (String s : args) {
System.out.println("Args: " + s);
}
}
RUN via IntelliJ:
3. Setup JAR
file --- project structure
artifacts (on left)
green + for new artifact
jar --- from modules with dependencies
pick the module to use [default likely OK]
choose the main class
4. Command line
java -jar out/artifacts/MyProjectName_jar/MyProjectName.jar Hello world!
Related Videos:
- GitLab feature branch and merge request without conflicts: youtu.be/heEtlAYONoo
- Advanced features and handling some special cases: (coming soon).
1. Android Studio: View "ME" changes:
- Highlight current branch "42-my-change"
- Log shows Branch
- View changes
2. Android Studio: Commit
- commit
- push
- show log
- switch to "master -) origin/master"
- show log
3. Merge Master to Feature
Merge master to feature when:
a) ready to merge Feature branch to master or
b) new code on master you want on feature branch.
- commit (if any changse)
- pull
- VCS -- Git -- Merge Changes...
current: Feature (42-my-change)
Branches to merge: master (local master)
- Build & test
- commit
- push
4. Create Merge Request on GitLab
- view log: Repository -- Network : Show ME and THEM branch
- Merge Request -- 'new merge request'
- View merge request's changes
(If conflicts: re-do merge master to feature.)
- Accept merge request
- view log: Repository -- Network : Show merged to master
5. Android Studio: Update
- show log
- highlight branch was: 42-my-change -- remote/42-my-change
- pull
- show log
- remove local branch: 42-my-change
[note no remote/42-my-change]
- show log
Overview:
- Create a GitLab issue
- Assign issue to self and create branch
- Checkout branch in Android Studio / IntelliJ
- Do coding, commit and push.
- In GitLab, create Merge Request, and delete branch
- In Android Studio switch to master, pull.
Related Videos:
- Setting up a GitLab project with Android Studio: youtube.com/watch?v=zprAqNffSjk
- Putting a button onto an Android Studio activity: youtube.com/watch?v=aE5f1tV5nU4
1.Setup
Create new Android Studio project
Create GitLab project;
Commit/push empty project.
2. Create GitLab issues:
“Add random number generation”
Assign issue to self
Create local branch via GitLab
3. In Android Studio, switch to branch:
Update project from Repo
Click the “Git: master” button on status bar bottom right:
Under remote, select the new branch you created
Then select “Checkout as new local branch”
4. Work:
Write code;
Commit/push (x2)
5. Create Merge Request:
On GitLab’s Merge Request page, select “Create Merge Request” for your recent push.
Select “Remove source branch when merge request is accepted.”
6. Accept Merge Request:
On GitLab’s Merge Request page
May be done by someone else if a code review is required.
View in Gitlab: Repository: Network
7. Set Android Studio Ready for Work:
Switch to master branch (bottom right, select Local Branch “origin/master”)
Pull or Update Project
Version Control: View log
MPAndroid Chart: github.com/PhilJay/MPAndroidChart
Wiki Getting Started: github.com/PhilJay/MPAndroidChart/wiki/Getting-Started
Wiki Setting Data: github.com/PhilJay/MPAndroidChart/wiki/Setting-Data
Steps:
1. Have data in a spread sheet. Clean out ','s from the data, then save as CSV file.
2. In Android project, create new resource directory
- type raw: gives name "raw"
- copy in file w/ copy/paste
3. Write code to read it.
- access the file via getResources().openRawResource(R.raw.vehicles_simple);
- use a BufferedReader to read one line at a time.
- call String.split() on the full line to create string tokens.
- parse the strings as needed and store in custom data objects.
- handle incorrectly formatted or missing data.
Steps:
- Setup MainActivity with a TextView to edit, and a button to trigger the dialog box.
- Create a layout XML file for the dialog's appearance
- Create a Java class inheriting from AppCompatDialogFragment to build the AlertDialog
- Show the AlertDialog from main using a fragment manager.
- Add a cancel button
- Call .finish() on the parent activity to close it.
Steps for pull/merge:
- Commit changes to local repo.
- Pull remote changes, triggers a merge conflict.
- Merge changes
- Commit changes to local repo.
- Push changes to remote repo.
Steps for "Update Project"
- VCS --- Update Project
- Commit
- Push


