11package life.qbic.datamodel.dtos.business
22
33import life.qbic.datamodel.dtos.business.facilities.Facility
4+ import life.qbic.datamodel.dtos.business.services.PrimaryAnalysis
45import life.qbic.datamodel.dtos.business.services.Product
56import life.qbic.datamodel.dtos.business.services.ProductUnit
67import life.qbic.datamodel.dtos.business.services.Sequencing
78import spock.lang.Specification
9+ import spock.lang.Unroll
810
911/**
1012 * Simple tests for the ProductItem dto class
@@ -25,6 +27,50 @@ class ProductItemSpec extends Specification {
2527 productItem. product == product
2628 }
2729
30+ def " Equal ProductItems shall be equal" () {
31+
32+ given : " two product item contents"
33+ def referenceProduct = new Sequencing (" RNA Sequencing" , " This package manages the pricing for all RNA sequencings" , 1.0 , 3.0 , ProductUnit . PER_SAMPLE , 1 , Facility . QBIC )
34+ Double referenceQuantity = 1.0
35+ Double referenceTotalPrice = 3.0
36+ Double referenceQuantityDiscount = 0.0
37+
38+ when : " two product items are created from the same content"
39+ ProductItem item1 = new ProductItem (referenceQuantity, referenceProduct, referenceTotalPrice, referenceQuantityDiscount)
40+ ProductItem item2 = new ProductItem (referenceQuantity, referenceProduct, referenceTotalPrice, referenceQuantityDiscount)
41+
42+ ProductItem item3 = new ProductItem (referenceQuantity, referenceProduct)
43+ ProductItem item4 = new ProductItem (referenceQuantity, referenceProduct)
44+
45+ then : " the product items are equal"
46+ item1 == item2
47+ item3 == item4
48+ }
49+
50+ @Unroll
51+ def " Different ProductItems shall be different for property #differentProperty" () {
52+
53+ given : " a reference product item and a different product"
54+ def referenceProduct = new Sequencing (" RNA Sequencing" , " This package manages the pricing for all RNA sequencings" , 1.0 , 3.0 , ProductUnit . PER_SAMPLE , 1 , Facility . QBIC )
55+ Double referenceQuantity = 1.0
56+ Double referenceTotalPrice = 3.0
57+ Double referenceQuantityDiscount = 0.0
58+
59+ when : " we create a product item with different information"
60+ ProductItem reference = new ProductItem (referenceQuantity, referenceProduct, referenceTotalPrice, referenceQuantityDiscount)
61+ ProductItem differentItem = new ProductItem (quantity, product, totalPrice, quantityDiscount)
62+
63+ then : " the product items are not equal"
64+ reference != differentItem
65+
66+ where : " for every property"
67+ differentProperty | quantity| product| totalPrice| quantityDiscount
68+ " quantity" | 1.0 +1 | new Sequencing (" RNA Sequencing" , " This package manages the pricing for all RNA sequencings" , 1.0 , 3.0 , ProductUnit . PER_SAMPLE , 1 , Facility . QBIC ) | 3.0 | 0.0
69+ " product" | 1.0 | new PrimaryAnalysis (" Test" , " Different description" , 1.0 , 3.0 , ProductUnit . PER_SAMPLE , 1 , Facility . QBIC ) | 3.0 | 0.0
70+ " totalPrice" | 1.0 | new Sequencing (" RNA Sequencing" , " This package manages the pricing for all RNA sequencings" , 1.0 , 3.0 , ProductUnit . PER_SAMPLE , 1 , Facility . QBIC ) | 3.0 +1 | 0.0
71+ " quantityDiscount" | 1.0 | new Sequencing (" RNA Sequencing" , " This package manages the pricing for all RNA sequencings" , 1.0 , 3.0 , ProductUnit . PER_SAMPLE , 1 , Facility . QBIC ) | 3.0 | 0.0 + 1
72+ }
73+
2874 def " Products shall be comparable" (){
2975 when :
3076
0 commit comments