use of com.qcadoo.mes.technologiesGenerator.customization.product.domain.ProductSuffixes in project mes by qcadoo.
the class TechnologyCustomizerTest method shouldCreateCustomizedTechnologyWithCopiedAndCustomizedProduct.
@Test
public final void shouldCreateCustomizedTechnologyWithCopiedAndCustomizedProduct() {
// given
Entity technologyCopy = mockTechnology(2L, true, null);
Entity technology = mockTechnology(1L, true, technologyCopy);
stubIsValid(technology, true);
Entity nodeProduct = mockProduct(ProductFamilyElementType.PRODUCTS_FAMILY);
Entity node = mockNodeEntity(technology, TechnologyStructureNodeType.COMPONENT, mockEntity(), nodeProduct);
stubIsValid(node, true);
stubNodeSearchResult(node);
Entity mainOpoc = mockEntity();
stubIsValid(mainOpoc, true);
Entity customizedProduct = mockEntity();
stubIsValid(customizedProduct, true);
stubProductCustomizer(customizedProduct);
String generatedTechNumber = "generatedTechNumber";
String generatedTechName = "generated tech name";
stubTechNameAndNumberGenerator(customizedProduct, generatedTechNumber, generatedTechName);
// when
Optional<Either<String, TechnologyId>> result = technologyCustomizer.customize(NODE_ID, mainProduct, generatorSettings, false);
// then
assertTrue(result.isPresent());
assertTrue(result.get().isRight());
assertEquals((long) result.get().getRight().get(), 2L);
verify(technologyOperationProductsCustomizer).customize(new TechnologyId(technologyCopy.getId()), mainProduct, customizedProduct, generatorSettings);
verify(technologyOperationProductsCustomizer, never()).prepareMainTechnologyProduct(anyEntity(), anyEntity());
verify(technologyNameAndNumberGenerator).generateName(customizedProduct);
verify(technologyNameAndNumberGenerator).generateNumber(customizedProduct);
verify(technologyCopy).setField(TechnologyFields.NUMBER, generatedTechNumber);
verify(technologyCopy).setField(TechnologyFields.NAME, generatedTechName);
verify(node).setField(GeneratorTreeNodeFields.PRODUCT_TECHNOLOGY, 2L);
verify(productCustomizer).findOrCreate(anyEntity(), anyEntity(), eq(new ProductSuffixes(new ProductNumberSuffix(MAIN_PROD_NUMBER), new ProductNameSuffix(MAIN_PROD_NAME))), any(GeneratorSettings.class));
}
Aggregations