mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-29 22:23:41 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
@@ -30,9 +30,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* Template View defines a consistent layout for rendering views, delegating dynamic content
|
||||
* rendering to subclasses.
|
||||
*
|
||||
* <p>In this example, the {@link TemplateView} class provides the skeleton for rendering views
|
||||
* with a header, dynamic content, and a footer. Subclasses {@link HomePageView} and
|
||||
* {@link ContactPageView} define the specific dynamic content for their respective views.
|
||||
* <p>In this example, the {@link TemplateView} class provides the skeleton for rendering views with
|
||||
* a header, dynamic content, and a footer. Subclasses {@link HomePageView} and {@link
|
||||
* ContactPageView} define the specific dynamic content for their respective views.
|
||||
*
|
||||
* <p>The {@link App} class demonstrates the usage of the Template View Pattern by rendering
|
||||
* instances of {@link HomePageView} and {@link ContactPageView}.
|
||||
|
||||
@@ -27,14 +27,13 @@ package com.iluwatar.templateview;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* ContactPageView implements the TemplateView and provides dynamic content specific to the contact page.
|
||||
* ContactPageView implements the TemplateView and provides dynamic content specific to the contact
|
||||
* page.
|
||||
*/
|
||||
@Slf4j
|
||||
public class ContactPageView extends TemplateView {
|
||||
|
||||
/**
|
||||
* Renders dynamic content for the contact page.
|
||||
*/
|
||||
/** Renders dynamic content for the contact page. */
|
||||
@Override
|
||||
protected void renderDynamicContent() {
|
||||
LOGGER.info("Contact us at: contact@example.com");
|
||||
|
||||
@@ -31,9 +31,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*/
|
||||
@Slf4j
|
||||
public class HomePageView extends TemplateView {
|
||||
/**
|
||||
* Renders dynamic content for the homepage.
|
||||
*/
|
||||
/** Renders dynamic content for the homepage. */
|
||||
@Override
|
||||
protected void renderDynamicContent() {
|
||||
LOGGER.info("Welcome to the Home Page!");
|
||||
|
||||
@@ -27,36 +27,28 @@ package com.iluwatar.templateview;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* TemplateView defines the skeleton for rendering views.
|
||||
* Concrete subclasses will provide the dynamic content for specific views.
|
||||
* TemplateView defines the skeleton for rendering views. Concrete subclasses will provide the
|
||||
* dynamic content for specific views.
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class TemplateView {
|
||||
|
||||
/**
|
||||
* Render the common structure of the view, delegating dynamic content to subclasses.
|
||||
*/
|
||||
/** Render the common structure of the view, delegating dynamic content to subclasses. */
|
||||
public final void render() {
|
||||
printHeader();
|
||||
renderDynamicContent();
|
||||
printFooter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the common header of the view.
|
||||
*/
|
||||
/** Prints the common header of the view. */
|
||||
protected void printHeader() {
|
||||
LOGGER.info("Rendering header...");
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses must provide the implementation for rendering dynamic content.
|
||||
*/
|
||||
/** Subclasses must provide the implementation for rendering dynamic content. */
|
||||
protected abstract void renderDynamicContent();
|
||||
|
||||
/**
|
||||
* Prints the common footer of the view.
|
||||
*/
|
||||
/** Prints the common footer of the view. */
|
||||
protected void printFooter() {
|
||||
LOGGER.info("Rendering footer...");
|
||||
}
|
||||
|
||||
@@ -24,17 +24,16 @@
|
||||
*/
|
||||
package com.iluwatar.templateview;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
* Application test
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Application test */
|
||||
class AppTest {
|
||||
|
||||
@Test
|
||||
void shouldExecuteWithoutException() {
|
||||
// Verify that main() method executes without throwing exceptions
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
*/
|
||||
package com.iluwatar.templateview;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ContactPageViewTest {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
*/
|
||||
package com.iluwatar.templateview;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class HomePageViewTest {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
*/
|
||||
package com.iluwatar.templateview;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class TemplateViewTest {
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user