mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-18 17:26:44 +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:
@@ -45,19 +45,13 @@ public class App {
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
final var scene = new Scene();
|
||||
var drawPixels1 = List.of(
|
||||
new MutablePair<>(1, 1),
|
||||
new MutablePair<>(5, 6),
|
||||
new MutablePair<>(3, 2)
|
||||
);
|
||||
var drawPixels1 =
|
||||
List.of(new MutablePair<>(1, 1), new MutablePair<>(5, 6), new MutablePair<>(3, 2));
|
||||
scene.draw(drawPixels1);
|
||||
var buffer1 = scene.getBuffer();
|
||||
printBlackPixelCoordinate(buffer1);
|
||||
|
||||
var drawPixels2 = List.of(
|
||||
new MutablePair<>(3, 7),
|
||||
new MutablePair<>(6, 1)
|
||||
);
|
||||
var drawPixels2 = List.of(new MutablePair<>(3, 7), new MutablePair<>(6, 1));
|
||||
scene.draw(drawPixels2);
|
||||
var buffer2 = scene.getBuffer();
|
||||
printBlackPixelCoordinate(buffer2);
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.doublebuffer;
|
||||
|
||||
/**
|
||||
* Buffer interface.
|
||||
*/
|
||||
/** Buffer interface. */
|
||||
public interface Buffer {
|
||||
|
||||
/**
|
||||
@@ -45,9 +43,7 @@ public interface Buffer {
|
||||
*/
|
||||
void draw(int x, int y);
|
||||
|
||||
/**
|
||||
* Clear all the pixels.
|
||||
*/
|
||||
/** Clear all the pixels. */
|
||||
void clearAll();
|
||||
|
||||
/**
|
||||
@@ -56,5 +52,4 @@ public interface Buffer {
|
||||
* @return pixel list
|
||||
*/
|
||||
Pixel[] getPixels();
|
||||
|
||||
}
|
||||
|
||||
@@ -26,9 +26,7 @@ package com.iluwatar.doublebuffer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* FrameBuffer implementation class.
|
||||
*/
|
||||
/** FrameBuffer implementation class. */
|
||||
public class FrameBuffer implements Buffer {
|
||||
|
||||
public static final int WIDTH = 10;
|
||||
|
||||
@@ -24,11 +24,8 @@
|
||||
*/
|
||||
package com.iluwatar.doublebuffer;
|
||||
|
||||
/**
|
||||
* Pixel enum. Each pixel can be white (not drawn) or black (drawn).
|
||||
*/
|
||||
/** Pixel enum. Each pixel can be white (not drawn) or black (drawn). */
|
||||
public enum Pixel {
|
||||
|
||||
WHITE,
|
||||
BLACK
|
||||
}
|
||||
|
||||
@@ -28,9 +28,7 @@ import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
/**
|
||||
* Scene class. Render the output frame.
|
||||
*/
|
||||
/** Scene class. Render the output frame. */
|
||||
@Slf4j
|
||||
public class Scene {
|
||||
|
||||
@@ -40,9 +38,7 @@ public class Scene {
|
||||
|
||||
private int next;
|
||||
|
||||
/**
|
||||
* Constructor of Scene.
|
||||
*/
|
||||
/** Constructor of Scene. */
|
||||
public Scene() {
|
||||
frameBuffers = new FrameBuffer[2];
|
||||
frameBuffers[0] = new FrameBuffer();
|
||||
@@ -60,11 +56,12 @@ public class Scene {
|
||||
LOGGER.info("Start drawing next frame");
|
||||
LOGGER.info("Current buffer: " + current + " Next buffer: " + next);
|
||||
frameBuffers[next].clearAll();
|
||||
coordinateList.forEach(coordinate -> {
|
||||
var x = coordinate.getKey();
|
||||
var y = coordinate.getValue();
|
||||
frameBuffers[next].draw(x, y);
|
||||
});
|
||||
coordinateList.forEach(
|
||||
coordinate -> {
|
||||
var x = coordinate.getKey();
|
||||
var y = coordinate.getValue();
|
||||
frameBuffers[next].draw(x, y);
|
||||
});
|
||||
LOGGER.info("Swap current and next buffer");
|
||||
swap();
|
||||
LOGGER.info("Finish swapping");
|
||||
@@ -81,5 +78,4 @@ public class Scene {
|
||||
next = current ^ next;
|
||||
current = current ^ next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,21 +28,17 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* App unit test.
|
||||
*/
|
||||
/** App unit test. */
|
||||
class AppTest {
|
||||
|
||||
/**
|
||||
* Issue: Add at least one assertion to this test case.
|
||||
* <p>
|
||||
* Solution: Inserted assertion to check whether the execution of the main method in {@link App#main(String[])}
|
||||
* throws an exception.
|
||||
*
|
||||
* <p>Solution: Inserted assertion to check whether the execution of the main method in {@link
|
||||
* App#main(String[])} throws an exception.
|
||||
*/
|
||||
|
||||
@Test
|
||||
void shouldExecuteApplicationWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,9 +30,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* FrameBuffer unit test.
|
||||
*/
|
||||
/** FrameBuffer unit test. */
|
||||
class FrameBufferTest {
|
||||
|
||||
@Test
|
||||
@@ -91,5 +89,4 @@ class FrameBufferTest {
|
||||
fail("Fail to modify field access.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,9 +30,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||
import java.util.ArrayList;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Scene unit tests.
|
||||
*/
|
||||
/** Scene unit tests. */
|
||||
class SceneTest {
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user