Skip to content

Commit 614a38b

Browse files
committed
Class Greetings Test build
Small Greeting array program to help test project testing when pushed to github and easily branched/committed to show functionalities
1 parent 9ed0694 commit 614a38b

File tree

5 files changed

+130
-0
lines changed

5 files changed

+130
-0
lines changed

.github/workflows/maven.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Java CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v1
12+
- name: Set up JDK 1.8
13+
uses: actions/setup-java@v1
14+
with:
15+
java-version: 1.8
16+
- name: Build with Maven
17+
run: mvn -B package --file pom.xml

pom.xml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.github.romankh3</groupId>
8+
<artifactId>maven-template-repository</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
12+
<name>Maven Repository Template</name>
13+
14+
<url>https://github.com/template-repository/maven-template-repository</url>
15+
16+
<licenses>
17+
<license>
18+
<name>The Apache Software License, Version 2.0</name>
19+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
20+
</license>
21+
</licenses>
22+
23+
<properties>
24+
<mockito.version>2.26.0</mockito.version>
25+
<junit.version>5.5.2</junit.version>
26+
<maven.compiler.source>1.8</maven.compiler.source>
27+
<maven.compiler.target>1.8</maven.compiler.target>
28+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
29+
<javadoc.plugin.version>3.1.1</javadoc.plugin.version>
30+
<source.plugin.version>3.2.0</source.plugin.version>
31+
<surefire.plugin.version>2.22.2</surefire.plugin.version>
32+
</properties>
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.mockito</groupId>
37+
<artifactId>mockito-core</artifactId>
38+
<version>${mockito.version}</version>
39+
<scope>test</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.junit.jupiter</groupId>
43+
<artifactId>junit-jupiter-api</artifactId>
44+
<version>${junit.version}</version>
45+
<scope>test</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.junit.jupiter</groupId>
49+
<artifactId>junit-jupiter-engine</artifactId>
50+
<version>${junit.version}</version>
51+
<scope>test</scope>
52+
</dependency>
53+
</dependencies>
54+
55+
<build>
56+
<plugins>
57+
<plugin>
58+
<groupId>org.apache.maven.plugins</groupId>
59+
<artifactId>maven-source-plugin</artifactId>
60+
<version>${source.plugin.version}</version>
61+
<executions>
62+
<execution>
63+
<id>attach-sources</id>
64+
<goals>
65+
<goal>jar</goal>
66+
</goals>
67+
</execution>
68+
</executions>
69+
</plugin>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-surefire-plugin</artifactId>
73+
<version>${surefire.plugin.version}</version>
74+
</plugin>
75+
</plugins>
76+
</build>
77+
78+
</project>

src/main/java/Greetings.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.util.ArrayList;
2+
import java.util.Collections;
3+
import java.util.List;
4+
5+
/** Holds a list of greetings supplied by the class. */
6+
public final class Greetings {
7+
8+
private static final List<String> MESSAGES = new ArrayList<>();
9+
static {
10+
MESSAGES.add("Hello from the teacher!");
11+
// students add exactly one line each:
12+
// MESSAGES.add("Hola — Alice P.");
13+
}
14+
15+
/** Returns an unmodifiable view of the greetings list. */
16+
public static List<String> all() {
17+
return Collections.unmodifiableList(MESSAGES);
18+
}
19+
}

src/main/java/Main.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class Main {
2+
public static void main(String[] args) {
3+
Greetings.all().forEach(System.out::println);
4+
}
5+
}

src/test/java/GreetingsTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import static org.junit.jupiter.api.Assertions.*;
2+
import org.junit.jupiter.api.Test;
3+
4+
class GreetingsTest {
5+
6+
@Test
7+
void atLeastOneGreeting() {
8+
assertFalse(Greetings.all().isEmpty(),
9+
"The class should have at least one greeting!");
10+
}
11+
}

0 commit comments

Comments
 (0)