-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
021d2f8
commit 4bbdbeb
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
java/src/test/java/com/amido/stacks/workloads/menu/domain/MenuTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.amido.stacks.workloads.menu.domain; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.UUID; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@Tag("Unit") | ||
public class MenuTest { | ||
|
||
@Test | ||
void shouldBuildMenu() { | ||
|
||
UUID id = UUID.randomUUID(); | ||
UUID restId = UUID.randomUUID(); | ||
|
||
Menu menu = | ||
Menu.builder() | ||
.id(id.toString()) | ||
.restaurantId(restId.toString()) | ||
.name("menu name") | ||
.description("menu desc") | ||
.enabled(true) | ||
.build(); | ||
|
||
assertEquals(id.toString(), menu.getId()); | ||
assertEquals(restId.toString(), menu.getRestaurantId()); | ||
assertEquals("menu name", menu.getName()); | ||
assertEquals("menu desc", menu.getDescription()); | ||
assertTrue(menu.getEnabled()); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
.../src/test/java/com/amido/stacks/workloads/menu/service/utility/MenuHelperServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.amido.stacks.workloads.menu.service.utility; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import com.amido.stacks.workloads.menu.domain.Category; | ||
import com.amido.stacks.workloads.menu.domain.Item; | ||
import com.amido.stacks.workloads.menu.domain.Menu; | ||
import java.util.UUID; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@Tag("Unit") | ||
class MenuHelperServiceTest { | ||
|
||
@Test | ||
void shouldAddOrUpdateCategoryIfMenuCategoriesNull() { | ||
|
||
Menu menu = | ||
new Menu( | ||
UUID.randomUUID().toString(), | ||
UUID.randomUUID().toString(), | ||
"menu name", | ||
"cat desc", | ||
null, | ||
true); | ||
|
||
MenuHelperService menuHelperService = new MenuHelperService(); | ||
menuHelperService.addOrUpdateCategory( | ||
menu, new Category(UUID.randomUUID().toString(), "cat name", "cat desc", null)); | ||
|
||
assertNotNull(menu.getCategories()); | ||
assertEquals(1, menu.getCategories().size()); | ||
} | ||
|
||
@Test | ||
void shouldAddOrUpdateItemIfCategoryItemsNull() { | ||
|
||
Category category = new Category(UUID.randomUUID().toString(), "cat name", "cat desc", null); | ||
|
||
Item item = new Item(UUID.randomUUID().toString(), "item name", "item desc", 100.0, true); | ||
|
||
MenuHelperService menuHelperService = new MenuHelperService(); | ||
menuHelperService.addOrUpdateItem(category, item); | ||
|
||
assertNotNull(category.getItems()); | ||
assertEquals(1, category.getItems().size()); | ||
} | ||
} |