diff --git a/demo/02/.gitignore b/demo/02/.gitignore new file mode 100644 index 0000000..2a91258 --- /dev/null +++ b/demo/02/.gitignore @@ -0,0 +1,201 @@ + +# Created by https://www.gitignore.io/api/java,maven,eclipse,intellij+all,visualstudiocode +# Edit at https://www.gitignore.io/?templates=java,maven,eclipse,intellij+all,visualstudiocode + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Annotation Processing +.apt_generated + +.sts4-cache/ + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# Ignores the whole .idea folder and all .iml files +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +# Sonarlint plugin +.idea/sonarlint + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.flattened-pom.xml + +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# Ignore all local history of files +.history + +# End of https://www.gitignore.io/api/java,maven,eclipse,intellij+all,visualstudiocode \ No newline at end of file diff --git a/demo/02/README.md b/demo/02/README.md new file mode 100644 index 0000000..cbb5bf6 --- /dev/null +++ b/demo/02/README.md @@ -0,0 +1 @@ +# Demonstracja TDD diff --git a/demo/02/pom.xml b/demo/02/pom.xml new file mode 100644 index 0000000..9ed57d9 --- /dev/null +++ b/demo/02/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + + pl.amu.edu + demo-02-testing + 1.0-SNAPSHOT + jar + + cw1 + + + UTF-8 + 11 + ${java.version} + ${java.version} + ${java.version} + + 1.18.24 + 5.9.0 + 3.23.1 + 4.8.0 + + + 3.2.2 + 3.8.1 + + + + + + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.mockito + mockito-junit-jupiter + ${mockito.version} + test + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven.shade} + + + package + + shade + + + + + org.example.App + + + + + + + + + diff --git a/demo/02/src/main/java/pl/amu/edu/demo/data/Address.java b/demo/02/src/main/java/pl/amu/edu/demo/data/Address.java new file mode 100644 index 0000000..6e13044 --- /dev/null +++ b/demo/02/src/main/java/pl/amu/edu/demo/data/Address.java @@ -0,0 +1,13 @@ +package pl.amu.edu.demo.data; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.experimental.FieldDefaults; + +@AllArgsConstructor +@FieldDefaults(level = AccessLevel.PUBLIC, makeFinal = true) +public class Address { + String addressLine1; + String addressLine2; + String zipCode; +} diff --git a/demo/02/src/main/java/pl/amu/edu/demo/data/Housing.java b/demo/02/src/main/java/pl/amu/edu/demo/data/Housing.java new file mode 100644 index 0000000..79d0f71 --- /dev/null +++ b/demo/02/src/main/java/pl/amu/edu/demo/data/Housing.java @@ -0,0 +1,12 @@ +package pl.amu.edu.demo.data; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.experimental.FieldDefaults; + +@AllArgsConstructor +@FieldDefaults(level = AccessLevel.PUBLIC, makeFinal = true) +public class Housing { + Address address; + boolean isApartment; +} diff --git a/demo/02/src/main/java/pl/amu/edu/demo/data/Person.java b/demo/02/src/main/java/pl/amu/edu/demo/data/Person.java new file mode 100644 index 0000000..e1b4463 --- /dev/null +++ b/demo/02/src/main/java/pl/amu/edu/demo/data/Person.java @@ -0,0 +1,18 @@ +package pl.amu.edu.demo.data; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.experimental.FieldDefaults; + +import java.time.LocalDate; + +@AllArgsConstructor +@FieldDefaults(level = AccessLevel.PUBLIC, makeFinal = true) +public class Person { + String displayName; + String firstName; + String lastName; + LocalDate birthDate; + Housing housing; + boolean isMarried; +} diff --git a/demo/02/src/main/java/pl/amu/edu/demo/providers/AverageQuoteProvider.java b/demo/02/src/main/java/pl/amu/edu/demo/providers/AverageQuoteProvider.java new file mode 100644 index 0000000..ab28966 --- /dev/null +++ b/demo/02/src/main/java/pl/amu/edu/demo/providers/AverageQuoteProvider.java @@ -0,0 +1,7 @@ +package pl.amu.edu.demo.providers; + +public interface AverageQuoteProvider { + + double getAverageQuotePerSquareMeter(String zipCode); + +} diff --git a/demo/02/src/test/java/TestStash.java b/demo/02/src/test/java/TestStash.java new file mode 100644 index 0000000..4c405ee --- /dev/null +++ b/demo/02/src/test/java/TestStash.java @@ -0,0 +1,27 @@ +import org.junit.jupiter.api.Test; +import pl.amu.edu.demo.data.Person; + +import java.time.LocalDate; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class TestStash { + + @Test + public void shouldWhatever() { + // given + var person = new Person("lama", "frama", "lama", LocalDate.now(), null, false); + + // when + var date = person.birthDate; + + // then +// assertThat(date).isNotNull(); + assertThrows(IllegalArgumentException.class, this::throwMeOut); + } + + private void throwMeOut() { + throw new IllegalArgumentException(); + } + +} diff --git a/demo/02/src/test/java/pl/amu/edu/demo/logic/TestWeWillStealYourFlatProduct.java b/demo/02/src/test/java/pl/amu/edu/demo/logic/TestWeWillStealYourFlatProduct.java new file mode 100644 index 0000000..9d444f4 --- /dev/null +++ b/demo/02/src/test/java/pl/amu/edu/demo/logic/TestWeWillStealYourFlatProduct.java @@ -0,0 +1,19 @@ +package pl.amu.edu.demo.logic; + +import org.junit.jupiter.api.Test; + +public class TestWeWillStealYourFlatProduct { + + @Test + public void shouldBeValid() { + // given + /* preconditions */ + + // when + /* when we perform an action */ + + // then + /* assert that everything works as expected */ + } + +}