Skip to content

fix: monitor pattern is not being built#1956

Merged
iluwatar merged 9 commits into
iluwatar:masterfrom
arnabsen1729:fix-monitor-build
Apr 16, 2022
Merged

fix: monitor pattern is not being built#1956
iluwatar merged 9 commits into
iluwatar:masterfrom
arnabsen1729:fix-monitor-build

Conversation

@arnabsen1729
Copy link
Copy Markdown
Contributor

@arnabsen1729 arnabsen1729 commented Jan 29, 2022

Description

This PR is a continuation to #1873. The build was failing after the monitor module was added to the pom.xml file because of checkstyle violations.

Fixes #1871

Changes

File Structure

Previously the file structure for the monitor was: (the test was nested inside main)

├── src
│   └── main
│       ├── test
│       │   └── java
│       │       └── com
│       │           └── iluwater
│       │               └── java
│       │                   └── BankTest.java
│       └── java
│           └── com
│               └── iluwatar
│                   └── monitor
│                       ├── Main.java
│                       └── Bank.java

For the other patterns, I noticed both the test and main were inside src.
So this PR updates it to :

├── src
│   ├── main
│   │   └── java
│   │       └── com
│   │           └── iluwatar
│   │               └── monitor
│   │                   ├── Bank.java
│   │                   └── Main.java
│   └── test
│       └── java
│           └── com
│               └── iluwatar
│                   └── monitor
│                       └── BankTest.java

Replaced the logger library

Replaced the java.util.logging.Logger with lombok.extern.slf4j.Slf4j. With this change, we don't need the Logger member variable anymore.

Also, this statement is flagged as a Minor Codesmell by Sonarcloud.

logger.info("Transferred from account :" + accountA + " to account :" + accountB + " , amount :" + amount + " . balance :" + getBalance());

But with the Slf4j logger usage, it didn't show any error.

LOGGER.info(
          "Transferred from account: {} to account: {} , amount: {} , balance: {}",
          accountA,
          accountB,
          amount,
          getBalance());

Fix CheckStyle errors

There were a few checkstyle error fixes like:

  • changing indentation with 4 spaces to 2 spaces.
  • Javadoc was missing in multiple instances.

Local Build Success Log
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for java-design-patterns 1.26.0-SNAPSHOT:
[INFO] 
[INFO] java-design-patterns ............................... SUCCESS [  2.728 s]
[INFO] abstract-factory ................................... SUCCESS [  3.582 s]
[INFO] monitor ............................................ SUCCESS [  1.293 s]
[INFO] tls ................................................ SUCCESS [  2.452 s]
[INFO] builder ............................................ SUCCESS [  2.283 s]
[INFO] factory-method ..................................... SUCCESS [  1.782 s]
[INFO] prototype .......................................... SUCCESS [  2.316 s]
[INFO] singleton .......................................... SUCCESS [  2.187 s]
[INFO] adapter ............................................ SUCCESS [  2.188 s]
[INFO] bridge ............................................. SUCCESS [  2.783 s]
[INFO] composite .......................................... SUCCESS [  1.678 s]
[INFO] dao ................................................ SUCCESS [  4.140 s]
[INFO] data-mapper ........................................ SUCCESS [  2.627 s]
[INFO] decorator .......................................... SUCCESS [  2.016 s]
[INFO] facade ............................................. SUCCESS [  1.687 s]
[INFO] flyweight .......................................... SUCCESS [  1.940 s]
[INFO] proxy .............................................. SUCCESS [  2.443 s]
[INFO] chain-of-responsibility ............................ SUCCESS [  1.691 s]
[INFO] command ............................................ SUCCESS [  1.855 s]
[INFO] interpreter ........................................ SUCCESS [  2.867 s]
[INFO] iterator ........................................... SUCCESS [  1.871 s]
[INFO] mediator ........................................... SUCCESS [  2.213 s]
[INFO] memento ............................................ SUCCESS [  1.654 s]
[INFO] model-view-presenter ............................... SUCCESS [  2.299 s]
[INFO] observer ........................................... SUCCESS [  2.635 s]
[INFO] state .............................................. SUCCESS [  1.856 s]
[INFO] strategy ........................................... SUCCESS [  2.049 s]
[INFO] template-method .................................... SUCCESS [  2.521 s]
[INFO] version-number ..................................... SUCCESS [  1.990 s]
[INFO] visitor ............................................ SUCCESS [  2.443 s]
[INFO] double-checked-locking ............................. SUCCESS [  1.633 s]
[INFO] servant ............................................ SUCCESS [  2.420 s]
[INFO] service-locator .................................... SUCCESS [  1.737 s]
[INFO] null-object ........................................ SUCCESS [  1.595 s]
[INFO] event-aggregator ................................... SUCCESS [  2.087 s]
[INFO] callback ........................................... SUCCESS [  1.522 s]
[INFO] execute-around ..................................... SUCCESS [  1.559 s]
[INFO] property ........................................... SUCCESS [  1.463 s]
[INFO] intercepting-filter ................................ SUCCESS [  3.484 s]
[INFO] producer-consumer .................................. SUCCESS [ 13.934 s]
[INFO] pipeline ........................................... SUCCESS [  1.848 s]
[INFO] poison-pill ........................................ SUCCESS [  2.191 s]
[INFO] reader-writer-lock ................................. SUCCESS [ 14.064 s]
[INFO] lazy-loading ....................................... SUCCESS [  7.710 s]
[INFO] service-layer ...................................... SUCCESS [  6.608 s]
[INFO] specification ...................................... SUCCESS [  2.720 s]
[INFO] tolerant-reader .................................... SUCCESS [  1.622 s]
[INFO] model-view-controller .............................. SUCCESS [  2.224 s]
[INFO] flux ............................................... SUCCESS [  2.708 s]
[INFO] double-dispatch .................................... SUCCESS [  1.766 s]
[INFO] multiton ........................................... SUCCESS [  1.647 s]
[INFO] resource-acquisition-is-initialization ............. SUCCESS [  1.924 s]
[INFO] thread-pool ........................................ SUCCESS [  6.933 s]
[INFO] twin ............................................... SUCCESS [  8.177 s]
[INFO] private-class-data ................................. SUCCESS [  1.999 s]
[INFO] object-pool ........................................ SUCCESS [  7.927 s]
[INFO] dependency-injection ............................... SUCCESS [  3.000 s]
[INFO] naked-objects ...................................... SUCCESS [  0.156 s]
[INFO] naked-objects-dom .................................. SUCCESS [  2.360 s]
[INFO] naked-objects-fixture .............................. SUCCESS [  0.352 s]
[INFO] naked-objects-integtests ........................... SUCCESS [  5.406 s]
[INFO] naked-objects-webapp ............................... SUCCESS [  6.276 s]
[INFO] front-controller ................................... SUCCESS [  2.150 s]
[INFO] repository ......................................... SUCCESS [ 12.751 s]
[INFO] async-method-invocation ............................ SUCCESS [  7.735 s]
[INFO] monostate .......................................... SUCCESS [  2.354 s]
[INFO] step-builder ....................................... SUCCESS [  2.338 s]
[INFO] business-delegate .................................. SUCCESS [  2.970 s]
[INFO] half-sync-half-async ............................... SUCCESS [  4.411 s]
[INFO] layers ............................................. SUCCESS [  9.878 s]
[INFO] eip-message-channel ................................ SUCCESS [  4.001 s]
[INFO] fluentinterface .................................... SUCCESS [  2.443 s]
[INFO] reactor ............................................ SUCCESS [ 14.098 s]
[INFO] caching ............................................ SUCCESS [  2.803 s]
[INFO] eip-publish-subscribe .............................. SUCCESS [  4.105 s]
[INFO] delegation ......................................... SUCCESS [  1.840 s]
[INFO] event-driven-architecture .......................... SUCCESS [  2.893 s]
[INFO] api-gateway ........................................ SUCCESS [  0.062 s]
[INFO] image-microservice ................................. SUCCESS [  4.751 s]
[INFO] price-microservice ................................. SUCCESS [  4.420 s]
[INFO] api-gateway-service ................................ SUCCESS [  5.279 s]
[INFO] factory-kit ........................................ SUCCESS [  2.047 s]
[INFO] feature-toggle ..................................... SUCCESS [  1.592 s]
[INFO] value-object ....................................... SUCCESS [  1.601 s]
[INFO] module ............................................. SUCCESS [  1.631 s]
[INFO] monad .............................................. SUCCESS [  1.571 s]
[INFO] mute-idiom ......................................... SUCCESS [  1.675 s]
[INFO] hexagonal .......................................... SUCCESS [  4.348 s]
[INFO] abstract-document .................................. SUCCESS [  1.560 s]
[INFO] aggregator-microservices ........................... SUCCESS [  0.053 s]
[INFO] information-microservice ........................... SUCCESS [  3.974 s]
[INFO] aggregator-service ................................. SUCCESS [  5.315 s]
[INFO] inventory-microservice ............................. SUCCESS [  5.179 s]
[INFO] promise ............................................ SUCCESS [  5.324 s]
[INFO] page-object ........................................ SUCCESS [  0.227 s]
[INFO] sample-application ................................. SUCCESS [  0.362 s]
[INFO] test-automation .................................... SUCCESS [  6.009 s]
[INFO] event-asynchronous ................................. SUCCESS [  5.822 s]
[INFO] event-queue ........................................ SUCCESS [ 16.844 s]
[INFO] queue-load-leveling ................................ SUCCESS [ 16.570 s]
[INFO] object-mother ...................................... SUCCESS [  1.107 s]
[INFO] data-bus ........................................... SUCCESS [  2.966 s]
[INFO] converter .......................................... SUCCESS [  1.906 s]
[INFO] guarded-suspension ................................. SUCCESS [  1.328 s]
[INFO] balking ............................................ SUCCESS [  1.463 s]
[INFO] extension-objects .................................. SUCCESS [  1.570 s]
[INFO] marker ............................................. SUCCESS [  1.341 s]
[INFO] cqrs ............................................... SUCCESS [  6.370 s]
[INFO] event-sourcing ..................................... SUCCESS [  1.716 s]
[INFO] data-transfer-object ............................... SUCCESS [  1.658 s]
[INFO] throttling ......................................... SUCCESS [  6.581 s]
[INFO] unit-of-work ....................................... SUCCESS [  2.037 s]
[INFO] partial-response ................................... SUCCESS [  1.989 s]
[INFO] eip-wire-tap ....................................... SUCCESS [ 12.294 s]
[INFO] eip-splitter ....................................... SUCCESS [ 12.577 s]
[INFO] eip-aggregator ..................................... SUCCESS [ 23.897 s]
[INFO] retry .............................................. SUCCESS [  1.686 s]
[INFO] dirty-flag ......................................... SUCCESS [  1.441 s]
[INFO] trampoline ......................................... SUCCESS [  1.460 s]
[INFO] serverless ......................................... SUCCESS [  5.412 s]
[INFO] ambassador ......................................... SUCCESS [ 24.271 s]
[INFO] acyclic-visitor .................................... SUCCESS [  1.642 s]
[INFO] collection-pipeline ................................ SUCCESS [  1.735 s]
[INFO] master-worker-pattern .............................. SUCCESS [  1.702 s]
[INFO] spatial-partition .................................. SUCCESS [  2.169 s]
[INFO] priority-queue ..................................... SUCCESS [  1.715 s]
[INFO] commander .......................................... SUCCESS [  5.893 s]
[INFO] typeobjectpattern .................................. SUCCESS [  2.069 s]
[INFO] bytecode ........................................... SUCCESS [  1.723 s]
[INFO] leader-election .................................... SUCCESS [  2.120 s]
[INFO] data-locality ...................................... SUCCESS [  1.739 s]
[INFO] subclass-sandbox ................................... SUCCESS [  1.355 s]
[INFO] circuit-breaker .................................... SUCCESS [  7.912 s]
[INFO] role-object ........................................ SUCCESS [  2.172 s]
[INFO] saga ............................................... SUCCESS [  2.572 s]
[INFO] double-buffer ...................................... SUCCESS [  2.411 s]
[INFO] sharding ........................................... SUCCESS [  1.964 s]
[INFO] game-loop .......................................... SUCCESS [  7.547 s]
[INFO] combinator ......................................... SUCCESS [  1.717 s]
[INFO] update-method ...................................... SUCCESS [  4.449 s]
[INFO] leader-followers ................................... SUCCESS [  4.672 s]
[INFO] strangler .......................................... SUCCESS [  1.992 s]
[INFO] arrange-act-assert ................................. SUCCESS [  1.398 s]
[INFO] transaction-script ................................. SUCCESS [  5.312 s]
[INFO] registry ........................................... SUCCESS [  1.938 s]
[INFO] filterer ........................................... SUCCESS [  2.553 s]
[INFO] factory ............................................ SUCCESS [  2.033 s]
[INFO] separated-interface ................................ SUCCESS [  2.412 s]
[INFO] special-case ....................................... SUCCESS [  2.399 s]
[INFO] parameter-object ................................... SUCCESS [  2.500 s]
[INFO] active-object ...................................... SUCCESS [  3.170 s]
[INFO] model-view-viewmodel ............................... SUCCESS [  9.490 s]
[INFO] composite-entity ................................... SUCCESS [  1.965 s]
[INFO] table-module ....................................... SUCCESS [  2.651 s]
[INFO] presentation ....................................... SUCCESS [  3.192 s]
[INFO] lockable-object .................................... SUCCESS [  8.443 s]
[INFO] fanout-fanin ....................................... SUCCESS [ 20.988 s]
[INFO] domain-model ....................................... SUCCESS [  3.583 s]
[INFO] composite-view ..................................... SUCCESS [  3.000 s]
[INFO] metadata-mapping ................................... SUCCESS [  7.739 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10:23 min
[INFO] Finished at: 2022-01-30T02:32:40+05:30
[INFO] ------------------------------------------------------------------------

@arnabsen1729
Copy link
Copy Markdown
Contributor Author

Here is the coverage of monitor/Main.java.

New codes are highlighted in light yellow. Code that is both new and not covered will be in darker yellow, with the red marker in the margin. Source

@arnabsen1729
Copy link
Copy Markdown
Contributor Author

@iluwatar The code coverage is 61% and SonarCloud requires > 80% of coverage. Can you guide me to improve the code coverage?

@HattoriHenzo
Copy link
Copy Markdown
Contributor

HattoriHenzo commented Feb 27, 2022

@arnabsen1729 Hi, you have to write tests that will pass througt the for loop and another test, that check if the exception is rised

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

85.7% 85.7% Coverage
0.0% 0.0% Duplication

@arnabsen1729
Copy link
Copy Markdown
Contributor Author

arnabsen1729 commented Feb 27, 2022

Thanks @HattoriHenzo the code coverage increased to 85.7%.

@iluwatar the PR is passing all the checks now ✔️

@iluwatar iluwatar self-assigned this Apr 16, 2022
@iluwatar iluwatar added this to the 1.26.0 milestone Apr 16, 2022
@iluwatar iluwatar merged commit b51bca1 into iluwatar:master Apr 16, 2022
@iluwatar
Copy link
Copy Markdown
Owner

Many thanks for the monitor pattern fix!
@all-contributors please add @arnabsen1729 for code

@allcontributors
Copy link
Copy Markdown
Contributor

@iluwatar

I've put up a pull request to add @arnabsen1729! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Monitor pattern is not being built

3 participants