Browse Source

Merge branch 'refactor/names'

* refactor/names:
  Associate RecipeCards with their own Panel type.
  Rename Recipe -> RecipeCard; RecipeFrame -> RecipeManagerFrame
  No redundancy in panel namespaces and class names.
  Relocate summary-type panels into a separate package.
  Rename Product -> Element
  Rename Card -> Phase
Sam Jaffe 5 years ago
parent
commit
b544d6db9b
22 changed files with 211 additions and 180 deletions
  1. 2 2
      src/main/lombok/org/leumasjaffe/recipe/RecipeManager.java
  2. 8 8
      src/main/lombok/org/leumasjaffe/recipe/controller/FileController.java
  3. 5 5
      src/main/lombok/org/leumasjaffe/recipe/model/Product.java
  4. 1 1
      src/main/lombok/org/leumasjaffe/recipe/model/Card.java
  5. 5 5
      src/main/lombok/org/leumasjaffe/recipe/model/Recipe.java
  6. 9 9
      src/main/lombok/org/leumasjaffe/recipe/view/ProductPanel.java
  7. 8 8
      src/main/lombok/org/leumasjaffe/recipe/view/CardPanel.java
  8. 43 0
      src/main/lombok/org/leumasjaffe/recipe/view/RecipeCardPanel.java
  9. 0 57
      src/main/lombok/org/leumasjaffe/recipe/view/RecipeFrame.java
  10. 38 0
      src/main/lombok/org/leumasjaffe/recipe/view/RecipeManagerFrame.java
  11. 8 8
      src/main/lombok/org/leumasjaffe/recipe/view/ProductSummaryPanel.java
  12. 4 4
      src/main/lombok/org/leumasjaffe/recipe/view/SummaryIngredientPanel.java
  13. 9 4
      src/main/lombok/org/leumasjaffe/recipe/view/SummaryPanel.java
  14. 4 4
      src/test/java/org/leumasjaffe/recipe/controller/FileControllerTest.java
  15. 5 5
      src/test/java/org/leumasjaffe/recipe/model/ProductTest.java
  16. 26 26
      src/test/java/org/leumasjaffe/recipe/model/CardTest.java
  17. 8 8
      src/test/java/org/leumasjaffe/recipe/model/RecipeTest.java
  18. 8 8
      src/test/java/org/leumasjaffe/recipe/view/ProductPanelTest.java
  19. 5 5
      src/test/java/org/leumasjaffe/recipe/view/CardPanelTest.java
  20. 7 6
      src/test/java/org/leumasjaffe/recipe/view/ProductSummaryPanelTest.java
  21. 5 4
      src/test/java/org/leumasjaffe/recipe/view/SummaryIngredientPanelTest.java
  22. 3 3
      src/test/resources/example.json

+ 2 - 2
src/main/lombok/org/leumasjaffe/recipe/RecipeManager.java

@@ -1,6 +1,6 @@
 package org.leumasjaffe.recipe;
 
-import org.leumasjaffe.recipe.view.RecipeFrame;
+import org.leumasjaffe.recipe.view.RecipeManagerFrame;
 
 import lombok.experimental.UtilityClass;
 
@@ -8,7 +8,7 @@ import lombok.experimental.UtilityClass;
 public class RecipeManager {
 
 	public void main(String[] args) {
-		new RecipeFrame().setVisible(true);
+		new RecipeManagerFrame().setVisible(true);
 	}
 
 }

+ 8 - 8
src/main/lombok/org/leumasjaffe/recipe/controller/FileController.java

@@ -10,7 +10,7 @@ import java.io.IOException;
 import java.io.Reader;
 import java.io.Writer;
 
-import org.leumasjaffe.recipe.model.Recipe;
+import org.leumasjaffe.recipe.model.RecipeCard;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
@@ -25,13 +25,13 @@ import lombok.experimental.NonFinal;
 @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
 public class FileController {
 	public static interface ViewModel {
-		void setModel(Recipe model);
+		void setModel(RecipeCard model);
 	}
 	
 	private static final ObjectMapper mapper;
 	SaveLoadHandle handle;
 	ViewModel viewmodel;
-	@NonFinal Recipe model = null;
+	@NonFinal RecipeCard model = null;
 	
 	static {
 		mapper = new ObjectMapper();
@@ -44,7 +44,7 @@ public class FileController {
 	}
 	
 	public void create() {
-		setModel(new Recipe());
+		setModel(new RecipeCard());
 	}
 	
 	public void save() {
@@ -69,7 +69,7 @@ public class FileController {
 	private void load(final Reader reader) {
 		try (Reader in = reader;
 				BufferedReader buf = new BufferedReader(in)) {
-			setModel(mapper.readValue(in, Recipe.class));
+			setModel(mapper.readValue(in, RecipeCard.class));
 		} catch (IOException ioe) {
 			handle.error(ioe);
 		}
@@ -84,8 +84,8 @@ public class FileController {
 		}
 	}
 	
-	private void setModel(Recipe recipe) {
-		this.model = recipe;
-		viewmodel.setModel(recipe);
+	private void setModel(RecipeCard card) {
+		this.model = card;
+		viewmodel.setModel(card);
 	}
 }

+ 5 - 5
src/main/lombok/org/leumasjaffe/recipe/model/Product.java

@@ -9,18 +9,18 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 @Data @EqualsAndHashCode(callSuper=false)
-public class Product extends Observable.Instance implements CompoundRecipeComponent {
+public class Element extends Observable.Instance implements CompoundRecipeComponent {
 	String name;
-	List<Card> cards;
+	List<Phase> phases;
 
 	@Override
 	public Stream<Ingredient> getIngredientsAsStream() {
-		return getComponents().flatMap(Card::getIngredientsAsStream)
+		return getComponents().flatMap(Phase::getIngredientsAsStream)
 				.map(i -> new Ingredient(i.getName(), "", i.getAmount()));
 	}
 
 	@Override
-	public Stream<Card> getComponents() {
-		return cards.stream();
+	public Stream<Phase> getComponents() {
+		return phases.stream();
 	}	
 }

+ 1 - 1
src/main/lombok/org/leumasjaffe/recipe/model/Card.java

@@ -12,7 +12,7 @@ import lombok.EqualsAndHashCode;
 import lombok.NonNull;
 
 @Data @EqualsAndHashCode(callSuper=false)
-public class Card extends Observable.Instance implements CompoundRecipeComponent {	
+public class Phase extends Observable.Instance implements CompoundRecipeComponent {	
 	int id = 0; // TODO Fix this
 	int[] dependsOn = {}; // decltype(id)[]
 	String vessel = "";

+ 5 - 5
src/main/lombok/org/leumasjaffe/recipe/model/Recipe.java

@@ -10,21 +10,21 @@ import javax.swing.ImageIcon;
 import lombok.Data;
 
 @Data
-public class Recipe implements CompoundRecipeComponent {
+public class RecipeCard implements CompoundRecipeComponent {
 	String title;
 	String description;
 	int servings;
 	// TODO: Nutrition information
 	Optional<ImageIcon> photo; // TODO JSONIZATION	
-	List<Product> products = new ArrayList<>();
+	List<Element> elements = new ArrayList<>();
 	
 	@Override
-	public Stream<Product> getComponents() {
-		return products.stream();
+	public Stream<Element> getComponents() {
+		return elements.stream();
 	}
 	
 	@Override
 	public Stream<Ingredient> getIngredientsAsStream() {
-		return getComponents().flatMap(Product::getIngredientsAsStream);
+		return getComponents().flatMap(Element::getIngredientsAsStream);
 	}
 }

+ 9 - 9
src/main/lombok/org/leumasjaffe/recipe/view/ProductPanel.java

@@ -5,8 +5,8 @@ import javax.swing.JScrollPane;
 
 import org.leumasjaffe.observer.ForwardingObservableListener;
 import org.leumasjaffe.observer.ObserverDispatch;
-import org.leumasjaffe.recipe.model.Card;
-import org.leumasjaffe.recipe.model.Product;
+import org.leumasjaffe.recipe.model.Phase;
+import org.leumasjaffe.recipe.model.Element;
 
 import lombok.AccessLevel;
 import lombok.experimental.FieldDefaults;
@@ -18,27 +18,27 @@ import javax.swing.JSeparator;
 
 @SuppressWarnings("serial")
 @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
-public class ProductPanel extends JScrollPane {
+public class ElementPanel extends JScrollPane {
 	JPanel panelViewPort;
-	ForwardingObservableListener<Product> listener = new ForwardingObservableListener<>();
+	ForwardingObservableListener<Element> listener = new ForwardingObservableListener<>();
 
-	public ProductPanel(Product product) {
+	public ElementPanel(Element element) {
 		JPanel panelColumnHeader = new JPanel();
 		setColumnHeaderView(panelColumnHeader);
 		
-		JButton btnAddStep = new JButton("Add Card");
+		JButton btnAddStep = new JButton("Add Phase");
 		panelColumnHeader.add(btnAddStep);
 		
 		panelViewPort = new JPanel();
 		setViewportView(panelViewPort);
 		panelViewPort.setLayout(new VerticalLayout(5));
 				
-		for (final Card card : product.getCards()) {
-			panelViewPort.add(new CardPanel(card));
+		for (final Phase phase : element.getPhases()) {
+			panelViewPort.add(new PhasePanel(phase));
 			panelViewPort.add(new JSeparator());
 		}
 		
-		listener.setObserved(product, product.getCards());
+		listener.setObserved(element, element.getPhases());
 	}
 	
 	@Override

+ 8 - 8
src/main/lombok/org/leumasjaffe/recipe/view/CardPanel.java

@@ -4,7 +4,7 @@ import javax.swing.JPanel;
 
 import org.leumasjaffe.observer.ForwardingObservableListener;
 import org.leumasjaffe.observer.ObserverDispatch;
-import org.leumasjaffe.recipe.model.Card;
+import org.leumasjaffe.recipe.model.Phase;
 import org.leumasjaffe.recipe.model.Preparation;
 import org.leumasjaffe.recipe.model.Rest;
 import org.leumasjaffe.recipe.model.Step;
@@ -17,17 +17,17 @@ import org.jdesktop.swingx.VerticalLayout;
 
 @SuppressWarnings("serial")
 @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
-public class CardPanel extends JPanel {
+public class PhasePanel extends JPanel {
 	@NonFinal int steps = 0;
-	ForwardingObservableListener<Card> listener = new ForwardingObservableListener<>();
+	ForwardingObservableListener<Phase> listener = new ForwardingObservableListener<>();
 
-	public CardPanel(final Card card) {		
+	public PhasePanel(final Phase phase) {		
 		setLayout(new VerticalLayout(5));
 		
-		card.getPreparation().ifPresent(this::addPrep);
-		card.getCooking().forEach(this::addStep);
-		card.getRest().ifPresent(this::addRest);
-		listener.setObserved(card, card.getCooking());
+		phase.getPreparation().ifPresent(this::addPrep);
+		phase.getCooking().forEach(this::addStep);
+		phase.getRest().ifPresent(this::addRest);
+		listener.setObserved(phase, phase.getCooking());
 	}
 	
 	void addPrep(final Preparation step) {

+ 43 - 0
src/main/lombok/org/leumasjaffe/recipe/view/RecipeCardPanel.java

@@ -0,0 +1,43 @@
+package org.leumasjaffe.recipe.view;
+
+import javax.swing.JSplitPane;
+
+import org.jdesktop.swingx.VerticalLayout;
+import org.leumasjaffe.recipe.controller.FileController;
+import org.leumasjaffe.recipe.model.Element;
+import org.leumasjaffe.recipe.model.RecipeCard;
+import org.leumasjaffe.recipe.view.summary.SummaryPanel;
+
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.experimental.FieldDefaults;
+
+import javax.swing.JPanel;
+
+@SuppressWarnings("serial")
+@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
+public class RecipeCardPanel extends JSplitPane implements FileController.ViewModel {
+	@Getter(AccessLevel.PACKAGE) SummaryPanel summaryPanel;
+	@Getter(AccessLevel.PACKAGE) JPanel rightPanel;
+	
+	public RecipeCardPanel() {
+		rightPanel = new JPanel();
+		rightPanel.setLayout(new VerticalLayout(5));
+		setRightComponent(rightPanel);
+		
+		summaryPanel = new SummaryPanel();
+		setLeftComponent(summaryPanel);
+	}
+
+	@Override
+	public void setModel(final RecipeCard card) {
+		rightPanel.removeAll();
+		summaryPanel.removeElements();
+		card.getElements().forEach(this::addElement);
+	}
+	
+	private void addElement(final Element comp) {
+		summaryPanel.addElement(comp);
+		rightPanel.add(new ElementPanel(comp));
+	}
+}

+ 0 - 57
src/main/lombok/org/leumasjaffe/recipe/view/RecipeFrame.java

@@ -1,57 +0,0 @@
-package org.leumasjaffe.recipe.view;
-
-import javax.swing.JFrame;
-import javax.swing.JTabbedPane;
-
-import org.leumasjaffe.recipe.controller.FileController;
-import org.leumasjaffe.recipe.model.Product;
-import org.leumasjaffe.recipe.model.Recipe;
-
-import lombok.AccessLevel;
-import lombok.experimental.FieldDefaults;
-
-import javax.swing.JMenuBar;
-import javax.swing.JMenu;
-
-@SuppressWarnings("serial")
-@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
-public class RecipeFrame extends JFrame implements FileController.ViewModel {
-	SummaryPanel summaryPanel;
-	JTabbedPane tabbedPane;
-	
-	public RecipeFrame() {
-		FileController fileController = new FileController(this);
-
-		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-		
-		JMenuBar menuBar = new JMenuBar();
-		setJMenuBar(menuBar);
-		
-		JMenu mnFile = new FileMenu(this, fileController);
-		menuBar.add(mnFile);
-				
-		tabbedPane = new JTabbedPane();
-		setContentPane(tabbedPane);
-
-		summaryPanel = new SummaryPanel();
-		tabbedPane.addTab("Summary", summaryPanel);
-		
-//		fileController.create();
-		fileController.open("src/test/resources/example.json");
-
-		pack();
-		repaint();
-		setVisible(true);
-	}
-	
-	@Override
-	public void setModel(final Recipe recipe) {
-		// TODO Clear underlying panels
-		recipe.getProducts().forEach(this::addProduct);
-	}
-	
-	private void addProduct(final Product comp) {
-		summaryPanel.addProduct(comp);
-		tabbedPane.addTab(comp.getName(), new ProductPanel(comp));
-	}
-}

+ 38 - 0
src/main/lombok/org/leumasjaffe/recipe/view/RecipeManagerFrame.java

@@ -0,0 +1,38 @@
+package org.leumasjaffe.recipe.view;
+
+import javax.swing.JFrame;
+
+import org.leumasjaffe.recipe.controller.FileController;
+
+import lombok.AccessLevel;
+import lombok.experimental.FieldDefaults;
+
+import javax.swing.JMenuBar;
+import javax.swing.JMenu;
+
+@SuppressWarnings("serial")
+@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
+public class RecipeManagerFrame extends JFrame {
+	
+	public RecipeManagerFrame() {
+		RecipeCardPanel panel = new RecipeCardPanel();
+		FileController fileController = new FileController(panel);
+
+		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+		
+		JMenuBar menuBar = new JMenuBar();
+		setJMenuBar(menuBar);
+		
+		JMenu mnFile = new FileMenu(this, fileController);
+		menuBar.add(mnFile);
+				
+		setContentPane(panel);
+
+//		fileController.create();
+		fileController.open("src/test/resources/example.json");
+
+		pack();
+		repaint();
+		setVisible(true);
+	}
+}

+ 8 - 8
src/main/lombok/org/leumasjaffe/recipe/view/ProductSummaryPanel.java

@@ -1,11 +1,11 @@
-package org.leumasjaffe.recipe.view;
+package org.leumasjaffe.recipe.view.summary;
 
 import javax.swing.JPanel;
 
 import org.jdesktop.swingx.VerticalLayout;
 import org.leumasjaffe.observer.ObservableListener;
 import org.leumasjaffe.observer.ObserverDispatch;
-import org.leumasjaffe.recipe.model.Product;
+import org.leumasjaffe.recipe.model.Element;
 
 import lombok.AccessLevel;
 import lombok.Getter;
@@ -19,12 +19,12 @@ import java.awt.GridBagConstraints;
 
 @SuppressWarnings("serial")
 @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
-public class ProductSummaryPanel extends JPanel {
-	ObservableListener<JPanel, Product> listener;
+public class ElementPanel extends JPanel {
+	ObservableListener<JPanel, Element> listener;
 	@Getter(AccessLevel.PACKAGE) JLabel lblProductName;
 	@Getter(AccessLevel.PACKAGE) JPanel panelIngredients;
 	
-	public ProductSummaryPanel(final Product product) {
+	public ElementPanel(final Element element) {
 		GridBagLayout gridBagLayout = new GridBagLayout();
 		gridBagLayout.columnWidths = new int[]{0, 0, 0};
 		gridBagLayout.rowHeights = new int[]{0, 0, 0};
@@ -32,7 +32,7 @@ public class ProductSummaryPanel extends JPanel {
 		gridBagLayout.rowWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
 		setLayout(gridBagLayout);
 		
-		lblProductName = new JLabel(product.getName());
+		lblProductName = new JLabel(element.getName());
 		GridBagConstraints gbc_lblProductName = new GridBagConstraints();
 		gbc_lblProductName.insets = new Insets(0, 0, 5, 5);
 		gbc_lblProductName.gridx = 0;
@@ -51,9 +51,9 @@ public class ProductSummaryPanel extends JPanel {
 		
 		listener = new ObservableListener<>(panelIngredients, (c, t) -> {
 			c.removeAll();
-			product.getIngredients().stream().map(SummaryIngredientPanel::new).forEach(c::add);
+			element.getIngredients().stream().map(IngredientPanel::new).forEach(c::add);
 		});
-		listener.setObserved(product);
+		listener.setObserved(element);
 	}
 	
 	@Override

+ 4 - 4
src/main/lombok/org/leumasjaffe/recipe/view/SummaryIngredientPanel.java

@@ -1,4 +1,4 @@
-package org.leumasjaffe.recipe.view;
+package org.leumasjaffe.recipe.view.summary;
 
 import javax.swing.JPanel;
 import java.awt.GridBagLayout;
@@ -24,13 +24,13 @@ import javax.swing.JLabel;
 
 @SuppressWarnings("serial")
 @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
-public class SummaryIngredientPanel extends JPanel {
-	ObservableListener<SummaryIngredientPanel, Ingredient> listener;
+public class IngredientPanel extends JPanel {
+	ObservableListener<IngredientPanel, Ingredient> listener;
 	@Getter(AccessLevel.PACKAGE) JTextField txtName;
 	@Getter(AccessLevel.PACKAGE) JFormattedTextField txtAmount;
 	@Getter(AccessLevel.PACKAGE) JTextField txtUnit;
 	
-	public SummaryIngredientPanel(final Ingredient ingredient) {
+	public IngredientPanel(final Ingredient ingredient) {
 		GridBagLayout gridBagLayout = new GridBagLayout();
 		gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0};
 		gridBagLayout.rowHeights = new int[]{0, 0};

+ 9 - 4
src/main/lombok/org/leumasjaffe/recipe/view/SummaryPanel.java

@@ -1,4 +1,4 @@
-package org.leumasjaffe.recipe.view;
+package org.leumasjaffe.recipe.view.summary;
 
 import java.awt.Dimension;
 import java.awt.GridBagConstraints;
@@ -12,7 +12,8 @@ import javax.swing.JTextField;
 import javax.swing.JTextPane;
 
 import org.jdesktop.swingx.VerticalLayout;
-import org.leumasjaffe.recipe.model.Product;
+import org.leumasjaffe.recipe.model.Element;
+import org.leumasjaffe.recipe.view.ImagePanel;
 
 import lombok.AccessLevel;
 import lombok.experimental.FieldDefaults;
@@ -89,8 +90,12 @@ public class SummaryPanel extends JPanel {
 		add(txtpnDescription, gbc_txtpnDescription);
 	}
 
-	void addProduct(final Product comp) {
-		panelIngredients.add(new ProductSummaryPanel(comp));
+	public void addElement(final Element comp) {
+		panelIngredients.add(new ElementPanel(comp));
 		panelIngredients.add(new JSeparator());
 	}
+	
+	public void removeElements() {
+		panelIngredients.removeAll();
+	}
 }

+ 4 - 4
src/test/java/org/leumasjaffe/recipe/controller/FileControllerTest.java

@@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.junit.platform.runner.JUnitPlatform;
 import org.junit.runner.RunWith;
-import org.leumasjaffe.recipe.model.Recipe;
+import org.leumasjaffe.recipe.model.RecipeCard;
 import org.mockito.ArgumentCaptor;
 import org.mockito.InOrder;
 import org.mockito.InjectMocks;
@@ -30,14 +30,14 @@ class FileControllerTest {
 	@Test
 	void testCanCreateNewModel() {
 		controller.create();
-		verify(viewmodel).setModel(any(Recipe.class));
+		verify(viewmodel).setModel(any(RecipeCard.class));
 	}
 
 	@Test
 	void testRepeatedCreatesProvideNewObjects() {
 		InOrder inOrder = inOrder(viewmodel);
-		final ArgumentCaptor<Recipe> first = ArgumentCaptor.forClass(Recipe.class);
-		final ArgumentCaptor<Recipe> second = ArgumentCaptor.forClass(Recipe.class);
+		final ArgumentCaptor<RecipeCard> first = ArgumentCaptor.forClass(RecipeCard.class);
+		final ArgumentCaptor<RecipeCard> second = ArgumentCaptor.forClass(RecipeCard.class);
 
 		controller.create();
 		inOrder.verify(viewmodel).setModel(first.capture());

+ 5 - 5
src/test/java/org/leumasjaffe/recipe/model/ProductTest.java

@@ -8,19 +8,19 @@ import java.util.Arrays;
 
 import org.junit.jupiter.api.Test;
 
-class ProductTest {
+class ElementTest {
 	private static final Amount _1g = new Amount("1 g");
 
 	@Test
 	void testMergesIngredientsWithDifferentPrep() {
-		final Product prod = new Product();
-		final Card card = new Card();
+		final Element prod = new Element();
+		final Phase phase = new Phase();
 		final Step step = new Step();
 		step.setIngredients(Arrays.asList(
 				new Ingredient("TEST", "A", _1g),
 				new Ingredient("TEST", "B", _1g)));
-		card.setCooking(Arrays.asList(step));
-		prod.setCards(Arrays.asList(card));
+		phase.setCooking(Arrays.asList(step));
+		prod.setPhases(Arrays.asList(phase));
 		assertThat(prod.getIngredients(), hasSize(1));
 		assertThat(prod.getIngredients(),
 				hasItem(new Ingredient("TEST", "", new Amount("2 g"))));

+ 26 - 26
src/test/java/org/leumasjaffe/recipe/model/CardTest.java

@@ -10,84 +10,84 @@ import java.util.Optional;
 
 import org.junit.jupiter.api.Test;
 
-class CardTest {
+class PhaseTest {
 	private static final Amount _1g = new Amount("1 g");
 	private static final Duration dur = new Duration(Duration.Display.SECONDS, false, 10, 20);
 
 	@Test
 	void cannotAddNullPreparation() {
-		final Card card = new Card();
-		assertThrows(NullPointerException.class, () -> card.setPreparation(null));
+		final Phase phase = new Phase();
+		assertThrows(NullPointerException.class, () -> phase.setPreparation(null));
 	}
 	
 	@Test
 	void testDurationIsZeroByDefault() {
-		final Card card = new Card();
-		assertEquals(Duration.ZERO, card.getDuration());
+		final Phase phase = new Phase();
+		assertEquals(Duration.ZERO, phase.getDuration());
 	}
 	
 	@Test
 	void testSumsTogetherStepDurations() {
-		final Card card = new Card();
+		final Phase phase = new Phase();
 		final Step step = new Step();
 		step.setDuration(dur);
-		card.setCooking(Arrays.asList(step, step));
+		phase.setCooking(Arrays.asList(step, step));
 		assertEquals(new Duration(Duration.Display.SECONDS, false, 20, 40),
-				card.getDuration());
+				phase.getDuration());
 	}
 	
 	@Test
 	void testDoesNotAddPrepDurationIfPresent() {
-		final Card card = new Card();
+		final Phase phase = new Phase();
 		final Preparation prep = new Preparation();
 		prep.setDuration(dur);
-		card.setPreparation(prep);
-		assertEquals(Duration.ZERO, card.getDuration());
+		phase.setPreparation(prep);
+		assertEquals(Duration.ZERO, phase.getDuration());
 	}
 	
 	@Test
 	void testDoesNotAddRestDurationIfPresent() {
-		final Card card = new Card();
+		final Phase phase = new Phase();
 		final Rest rest = new Rest();
 		rest.setWhere(Rest.Where.REFRIGERATOR);
 		rest.setDuration(dur);
-		card.setRest(Optional.of(rest));
-		assertEquals(Duration.ZERO, card.getDuration());
+		phase.setRest(Optional.of(rest));
+		assertEquals(Duration.ZERO, phase.getDuration());
 	}
 
 	@Test
 	void testMergesLikeIngredients() {
-		final Card card = new Card();
+		final Phase phase = new Phase();
 		final Step step = new Step();
 		step.setIngredients(Arrays.asList(new Ingredient("TEST", "", _1g)));
-		card.setCooking(Arrays.asList(step, step));
-		assertThat(card.getIngredients(), hasSize(1));
-		assertThat(card.getIngredients(),
+		phase.setCooking(Arrays.asList(step, step));
+		assertThat(phase.getIngredients(), hasSize(1));
+		assertThat(phase.getIngredients(),
 				hasItem(new Ingredient("TEST", "", new Amount("2 g"))));
 	}
 
 	@Test
 	void testDoesNotMergeIngredientsWithDifferentPrep() {
-		final Card card = new Card();
+		final Phase phase = new Phase();
 		final Step step = new Step();
 		step.setIngredients(Arrays.asList(
 				new Ingredient("TEST", "A", _1g),
 				new Ingredient("TEST", "B", _1g)));
-		card.setCooking(Arrays.asList(step));
-		assertThat(card.getIngredients(), hasSize(2));
+		phase.setCooking(Arrays.asList(step));
+		assertThat(phase.getIngredients(), hasSize(2));
 	}
 
 	@Test
 	void testPrepIngredientsAreCardIngredientsWithPrep() {
-		final Card card = new Card();
+		final Phase phase = new Phase();
 		final Step step = new Step();
 		step.setIngredients(Arrays.asList(
 				new Ingredient("A", "", _1g),
 				new Ingredient("B", "TEST", _1g)));
-		card.setCooking(Arrays.asList(step));
-		card.setPreparation(new Preparation());
-		assertThat(card.getIngredients(), hasSize(2));
-		final Preparation prep = card.getPreparation().get();
+		phase.setCooking(Arrays.asList(step));
+		phase.setPreparation(new Preparation());
+		assertThat(phase.getIngredients(), hasSize(2));
+		final Preparation prep = phase.getPreparation().get();
 		assertThat(prep.getIngredients(), hasSize(1));
 		assertThat(prep.getIngredients(), hasItem(new Ingredient("B", "TEST", _1g)));
 	}

+ 8 - 8
src/test/java/org/leumasjaffe/recipe/model/RecipeTest.java

@@ -13,18 +13,18 @@ class RecipeTest {
 
 	@Test
 	void testMergesIngredientsWithDifferentPrep() {
-		final Recipe recipe = new Recipe();
-		final Product prod = new Product();
-		final Card card = new Card();
+		final RecipeCard card = new RecipeCard();
+		final Element prod = new Element();
+		final Phase phase = new Phase();
 		final Step step = new Step();
 		step.setIngredients(Arrays.asList(
 				new Ingredient("TEST", "A", _1g),
 				new Ingredient("TEST", "B", _1g)));
-		card.setCooking(Arrays.asList(step));
-		prod.setCards(Arrays.asList(card));
-		recipe.setProducts(Arrays.asList(prod, prod));
-		assertThat(recipe.getIngredients(), hasSize(1));
-		assertThat(recipe.getIngredients(),
+		phase.setCooking(Arrays.asList(step));
+		prod.setPhases(Arrays.asList(phase));
+		card.setElements(Arrays.asList(prod, prod));
+		assertThat(card.getIngredients(), hasSize(1));
+		assertThat(card.getIngredients(),
 				hasItem(new Ingredient("TEST", "", new Amount("4 g"))));
 	}
 

+ 8 - 8
src/test/java/org/leumasjaffe/recipe/view/ProductPanelTest.java

@@ -11,25 +11,25 @@ import org.junit.platform.runner.JUnitPlatform;
 import org.junit.runner.RunWith;
 import org.leumasjaffe.mock.MockObserverListener;
 import org.leumasjaffe.observer.ObserverDispatch;
-import org.leumasjaffe.recipe.model.Card;
-import org.leumasjaffe.recipe.model.Product;
+import org.leumasjaffe.recipe.model.Phase;
+import org.leumasjaffe.recipe.model.Element;
 import org.mockito.Mock;
 import org.mockito.Spy;
 import org.mockito.junit.jupiter.MockitoExtension;
 
 @ExtendWith(MockitoExtension.class)
 @RunWith(JUnitPlatform.class)
-class ProductPanelTest extends SwingTestCase {
+class ElementPanelTest extends SwingTestCase {
 	
 	@Spy MockObserverListener listener;
-	final Card stub = new Card();
-	@Mock Product stuff;
-	ProductPanel panel;
+	final Phase stub = new Phase();
+	@Mock Element stuff;
+	ElementPanel panel;
 
 	@BeforeEach
 	void setUp() {
-		doReturn(Arrays.asList(stub)).when(stuff).getCards();
-		panel = new ProductPanel(stuff);
+		doReturn(Arrays.asList(stub)).when(stuff).getPhases();
+		panel = new ElementPanel(stuff);
 		
 		listener.setObserved(stuff);
 		// setObserved() calls update

+ 5 - 5
src/test/java/org/leumasjaffe/recipe/view/CardPanelTest.java

@@ -11,7 +11,7 @@ import org.junit.platform.runner.JUnitPlatform;
 import org.junit.runner.RunWith;
 import org.leumasjaffe.mock.MockObserverListener;
 import org.leumasjaffe.observer.ObserverDispatch;
-import org.leumasjaffe.recipe.model.Card;
+import org.leumasjaffe.recipe.model.Phase;
 import org.leumasjaffe.recipe.model.Step;
 import org.mockito.Mock;
 import org.mockito.Spy;
@@ -19,17 +19,17 @@ import org.mockito.junit.jupiter.MockitoExtension;
 
 @ExtendWith(MockitoExtension.class)
 @RunWith(JUnitPlatform.class)
-class CardPanelTest extends SwingTestCase {
+class PhasePanelTest extends SwingTestCase {
 	
 	@Spy MockObserverListener listener;
 	final Step stub = new Step();
-	@Mock Card stuff;
-	CardPanel panel;
+	@Mock Phase stuff;
+	PhasePanel panel;
 
 	@BeforeEach
 	void setUp() {
 		doReturn(Arrays.asList(stub)).when(stuff).getCooking();
-		panel = new CardPanel(stuff);
+		panel = new PhasePanel(stuff);
 		
 		listener.setObserved(stuff);
 		// setObserved() calls update

+ 7 - 6
src/test/java/org/leumasjaffe/recipe/view/ProductSummaryPanelTest.java

@@ -1,4 +1,4 @@
-package org.leumasjaffe.recipe.view;
+package org.leumasjaffe.recipe.view.summary;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsArrayWithSize.arrayWithSize;
@@ -15,16 +15,17 @@ import org.junit.runner.RunWith;
 import org.leumasjaffe.observer.ObserverDispatch;
 import org.leumasjaffe.recipe.model.Amount;
 import org.leumasjaffe.recipe.model.Ingredient;
-import org.leumasjaffe.recipe.model.Product;
+import org.leumasjaffe.recipe.view.SwingTestCase;
+import org.leumasjaffe.recipe.model.Element;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 
 @ExtendWith(MockitoExtension.class)
 @RunWith(JUnitPlatform.class)
-class ProductSummaryPanelTest extends SwingTestCase {
+class ElementPanelTest extends SwingTestCase {
 	
-	@Mock Product stuff;
-	ProductSummaryPanel panel;
+	@Mock Element stuff;
+	ElementPanel panel;
 	
 	@BeforeEach
 	void setUp() {
@@ -34,7 +35,7 @@ class ProductSummaryPanelTest extends SwingTestCase {
 				new Ingredient("Garlic", "", new Amount("2 tsp"))))
 		.when(stuff).getIngredients();
 		
-		panel = new ProductSummaryPanel(stuff);
+		panel = new ElementPanel(stuff);
 	}
 
 	@Test

+ 5 - 4
src/test/java/org/leumasjaffe/recipe/view/SummaryIngredientPanelTest.java

@@ -1,4 +1,4 @@
-package org.leumasjaffe.recipe.view;
+package org.leumasjaffe.recipe.view.summary;
 
 import static org.junit.jupiter.api.Assertions.*;
 
@@ -7,16 +7,17 @@ import org.junit.jupiter.api.Test;
 import org.leumasjaffe.observer.ObserverDispatch;
 import org.leumasjaffe.recipe.model.Amount;
 import org.leumasjaffe.recipe.model.Ingredient;
+import org.leumasjaffe.recipe.view.SwingTestCase;
 
-class SummaryIngredientPanelTest extends SwingTestCase {
+class IngredientPanelTest extends SwingTestCase {
 
 	Ingredient stuff;
-	SummaryIngredientPanel panel;
+	IngredientPanel panel;
 	
 	@BeforeEach
 	void setUp() {
 		stuff = new Ingredient("Onions", "Sliced", new Amount("100 g"));
-		panel = new SummaryIngredientPanel(stuff);
+		panel = new IngredientPanel(stuff);
 	}
 
 	@Test

+ 3 - 3
src/test/resources/example.json

@@ -1,10 +1,10 @@
 {
   "title": "Peanut Chicken Curry",
   "description": "A fusion style peanut-butter based chicken curry from Chef John of FoodWishes.com",
-  "products": [
+  "elements": [
     {
       "name": "Curry",
-      "cards": [
+      "phases": [
         {
           "id": 0,
           "dependsOn": [],
@@ -56,7 +56,7 @@
             "duration": {
               "displayAs": "SECONDS",
               "approximate": false,
-              "minSeconds": 30,
+              "minSeconds": 0,
               "maxSeconds": 30
             }
           }