Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": ["esbenp.prettier-vscode", "vscjava.vscode-java-pack"]
"extensions": [
"esbenp.prettier-vscode",
"vscjava.vscode-java-pack",
"vmware.vscode-boot-dev-pack",
"cweijan.vscode-mysql-client2",
"GitHub.vscode-pull-request-github",
"bierner.github-markdown-preview",
"Postman.postman-for-vscode"
]
}
}
},

"forwardPorts": [8080]
}
84 changes: 84 additions & 0 deletions .github/workflows/slack-pr-merged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Notify Slack

on:
pull_request:
types: [closed]
branches:
- main
push:
branches:
- main

jobs:
notify-slack:
if: |
(github.event_name == 'pull_request' && github.event.pull_request.merged == true && success()) ||
(github.event_name == 'push' && !contains(github.event.head_commit.message, 'Merge pull request') && success())
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get changes
id: get-changes
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
# Get PR changes
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | sed '2,$s/^/ • /')
DESCRIPTION=$(echo "${{ github.event.pull_request.body }}" | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}')
TITLE=$(echo "${{ github.event.pull_request.title }}" | sed 's/"/\\"/g' | sed '2,$s/^/ /')
AUTHOR="${{ github.event.pull_request.user.login }}"
URL="${{ github.event.pull_request.html_url }}"
else
# Get push changes
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | sed '2,$s/^/ • /')

# Split commit message into title and description
COMMIT_MSG="${{ github.event.head_commit.message }}"
TITLE=$(echo "$COMMIT_MSG" | head -n1 | sed 's/"/\\"/g')
DESCRIPTION=$(echo "$COMMIT_MSG" | tail -n +2 | sed '/./,$!d' | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}')

AUTHOR="${{ github.event.head_commit.author.username }}"
URL="${{ github.event.head_commit.url }}"
fi

echo "changed_files<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

echo "description=$DESCRIPTION" >> $GITHUB_OUTPUT
echo "title=$TITLE" >> $GITHUB_OUTPUT
echo "author=$AUTHOR" >> $GITHUB_OUTPUT
echo "url=$URL" >> $GITHUB_OUTPUT

- name: Send to Slack
if: success()
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ vars.SLACK_CHANNEL_ID }}
text: "GitHub Action build result: ${{ job.status }}\n${{ steps.get-changes.outputs.url }}"
blocks:
- type: header
text:
type: plain_text
text: "🎉 Repo Updated! 🎉"
emoji: true
- type: section
text:
type: mrkdwn
text: "<https://github.com/${{ steps.get-changes.outputs.author }}|${{ steps.get-changes.outputs.author }}> contributed <${{ steps.get-changes.outputs.url }}|${{ steps.get-changes.outputs.title }}>"
${{ steps.get-changes.outputs.description != '' && steps.get-changes.outputs.description != null && format('- type: section
text:
type: mrkdwn
text: "{0}"', steps.get-changes.outputs.description) || '' }}
- type: section
text:
type: mrkdwn
text: |
*Changed Files:*
• ${{ steps.get-changes.outputs.changed_files }}
2 changes: 1 addition & 1 deletion exercises/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class HelloWorld {

:hourglass: **Compile**

In your terminal, navigate to the `getting-started` directory.
In your terminal, navigate to the `exercises/getting-started` directory.

Execute this command to **compile** our Java program

Expand Down
20 changes: 20 additions & 0 deletions exercises/getting-started/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.cbfacademy</groupId>
<artifactId>getting-started</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<sourceDirectory>${project.basedir}</sourceDirectory>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.cbfacademy.cars;

public class App {
public static void main(String[] args) {
// TODO: Display details of all cars in showroom
}
}
35 changes: 35 additions & 0 deletions exercises/software-dev-processes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
21 changes: 21 additions & 0 deletions exercises/software-dev-processes/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Coding Black Females

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
111 changes: 111 additions & 0 deletions exercises/software-dev-processes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Software Development Processes

[![Java Language](https://img.shields.io/badge/PLATFORM-OpenJDK-3A75B0.svg?style=for-the-badge)][1]
[![JUnit5 Testing Framework](https://img.shields.io/badge/testing%20framework-JUnit5-26A162.svg?style=for-the-badge)][2]
[![Maven Dependency Manager](https://img.shields.io/badge/dependency%20manager-Maven-AA215A.svg?style=for-the-badge)][3]

A simple project to practice writing JUnit 5 tests.

This short guide describes:

- [Getting Started][4]
- [Exercise 1][5]
- [Exercise 2][6]
- [Exercise 3][7]

## Getting Started

In your terminal, navigate to the `software-dev-processes` directory, then run the following command to compile the application:

```shell
./mvnw clean validate
```

If you're using the Windows Command Prompt, run this command instead:

```shell
mvnw clean validate
```

You should see the following console output:

```bash
$ ./mvnw clean validate

[INFO] Scanning for projects...
[INFO]
[INFO] --------------< com.cbfacademy:software-dev-processes >-----------------
[INFO] Building software-dev-processes 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[More download messages...]
[INFO]
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ software-dev-processes ---
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-api-2.0.6.pom
[More download messages...]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.155 s
[INFO] Finished at: 2022-11-03T20:56:09Z
[INFO] ------------------------------------------------------------------------
```

## Exercise 1

Examine the class implemented in `src/main/java/com/cbfacademy/Calculator.java`.
Create a test class at `src/test/java/com/cbfacademy/CalculatorTest.java`.
Write tests to ensure the Calculator can correctly multiply two numbers.\
Think of all possible scenarios, and write a test for each of the scenarios you come up with.

To run the tests, use the following command:

```shell
./mvnw clean test
```

To run a specific test method, you can modify the command to include the test class and method. For example, to run a method called `testAddition` in the `CalculatorTest` class, use the following command:
```shell
./mvnw clean test -Dtest=CalculatorTest#testAddition
```

Or for the Windows Command Prompt:
```shell
mvnw clean test -Dtest=CalculatorTest#testAddition
```

Once all your tests are passing, commit your changes.

## Exercise 2

Write tests to ensure the Calculator can divide two numbers.\
Think of all possible scenarios, and write a test for each of the scenarios.\
One of the scenarios should uncover a flaw in the Calculator implementation.

Run the tests, e.g.:
```shell
./mvnw clean test -Dtest=CalculatorTest#testDivision
```

Or for the Windows Command Prompt:
```shell
mvnw clean test -Dtest=CalculatorTest#testDivision
```

Once all your tests are passing, commit your changes.

## Exercise 3

Add more scenarios to cover the calculator's addition and subtraction functionalities.

Once all your tests are passing, commit your changes and push your branch to GitHub.

Enjoy working on your exercise! :smiley:

[1]: https://docs.oracle.com/javase/21/docs/api/index.html
[2]: https://junit.org/junit5/
[3]: https://maven.apache.org/
[4]: #getting-started
[5]: #exercise-1
[6]: #exercise-2
[7]: #exercise-3
Loading