📍Use lombok, reformat, and optimize the code (#1560)
* Use lombok, reformat, and optimize the code * Fix merge conflicts and some sonar issues Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
@ -23,18 +23,16 @@
|
||||
|
||||
package com.iluwatar.flux.action;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Action is the data payload dispatched to the stores when something happens.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public abstract class Action {
|
||||
|
||||
private final ActionType type;
|
||||
|
||||
public Action(ActionType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ActionType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ package com.iluwatar.flux.action;
|
||||
*/
|
||||
public enum ActionType {
|
||||
|
||||
MENU_ITEM_SELECTED, CONTENT_CHANGED
|
||||
MENU_ITEM_SELECTED,
|
||||
CONTENT_CHANGED
|
||||
|
||||
}
|
||||
|
@ -23,20 +23,19 @@
|
||||
|
||||
package com.iluwatar.flux.action;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Content items.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public enum Content {
|
||||
|
||||
PRODUCTS("Products - This page lists the company's products."), COMPANY(
|
||||
"Company - This page displays information about the company.");
|
||||
PRODUCTS("Products - This page lists the company's products."),
|
||||
COMPANY("Company - This page displays information about the company.");
|
||||
|
||||
private final String title;
|
||||
|
||||
Content(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
|
@ -26,16 +26,14 @@ package com.iluwatar.flux.view;
|
||||
import com.iluwatar.flux.action.Content;
|
||||
import com.iluwatar.flux.store.ContentStore;
|
||||
import com.iluwatar.flux.store.Store;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* ContentView is a concrete view.
|
||||
*/
|
||||
@Slf4j
|
||||
public class ContentView implements View {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ContentView.class);
|
||||
|
||||
private Content content = Content.PRODUCTS;
|
||||
|
||||
@Override
|
||||
|
@ -27,16 +27,14 @@ import com.iluwatar.flux.action.MenuItem;
|
||||
import com.iluwatar.flux.dispatcher.Dispatcher;
|
||||
import com.iluwatar.flux.store.MenuStore;
|
||||
import com.iluwatar.flux.store.Store;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* MenuView is a concrete view.
|
||||
*/
|
||||
@Slf4j
|
||||
public class MenuView implements View {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MenuView.class);
|
||||
|
||||
private MenuItem selected = MenuItem.HOME;
|
||||
|
||||
@Override
|
||||
|
@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test;
|
||||
public class ContentTest {
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
for (final var content : Content.values()) {
|
||||
final var toString = content.toString();
|
||||
assertNotNull(toString);
|
||||
|
@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test;
|
||||
public class MenuItemTest {
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
for (final var menuItem : MenuItem.values()) {
|
||||
final var toString = menuItem.toString();
|
||||
assertNotNull(toString);
|
||||
|
@ -38,7 +38,6 @@ import com.iluwatar.flux.action.ContentAction;
|
||||
import com.iluwatar.flux.action.MenuAction;
|
||||
import com.iluwatar.flux.action.MenuItem;
|
||||
import com.iluwatar.flux.store.Store;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -67,13 +66,13 @@ public class DispatcherTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInstance() {
|
||||
void testGetInstance() {
|
||||
assertNotNull(Dispatcher.getInstance());
|
||||
assertSame(Dispatcher.getInstance(), Dispatcher.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMenuItemSelected() {
|
||||
void testMenuItemSelected() {
|
||||
final var dispatcher = Dispatcher.getInstance();
|
||||
|
||||
final var store = mock(Store.class);
|
||||
|
@ -46,7 +46,7 @@ import org.junit.jupiter.api.Test;
|
||||
public class ContentStoreTest {
|
||||
|
||||
@Test
|
||||
public void testOnAction() {
|
||||
void testOnAction() {
|
||||
final var contentStore = new ContentStore();
|
||||
|
||||
final var view = mock(View.class);
|
||||
|
@ -46,7 +46,7 @@ import org.junit.jupiter.api.Test;
|
||||
public class MenuStoreTest {
|
||||
|
||||
@Test
|
||||
public void testOnAction() {
|
||||
void testOnAction() {
|
||||
final var menuStore = new MenuStore();
|
||||
|
||||
final var view = mock(View.class);
|
||||
|
@ -41,7 +41,7 @@ import org.junit.jupiter.api.Test;
|
||||
public class ContentViewTest {
|
||||
|
||||
@Test
|
||||
public void testStoreChanged() {
|
||||
void testStoreChanged() {
|
||||
final var store = mock(ContentStore.class);
|
||||
when(store.getContent()).thenReturn(Content.PRODUCTS);
|
||||
|
||||
|
@ -45,7 +45,7 @@ import org.junit.jupiter.api.Test;
|
||||
public class MenuViewTest {
|
||||
|
||||
@Test
|
||||
public void testStoreChanged() {
|
||||
void testStoreChanged() {
|
||||
final var store = mock(MenuStore.class);
|
||||
when(store.getSelected()).thenReturn(MenuItem.HOME);
|
||||
|
||||
@ -57,7 +57,7 @@ public class MenuViewTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItemClicked() {
|
||||
void testItemClicked() {
|
||||
final var store = mock(Store.class);
|
||||
Dispatcher.getInstance().registerStore(store);
|
||||
|
||||
|
Reference in New Issue
Block a user