Search in sources :

Example 1 with ProductNumberSuffix

use of com.qcadoo.mes.technologiesGenerator.customization.product.domain.ProductNumberSuffix 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));
}
Also used : QcadooModelMatchers.anyEntity(com.qcadoo.testing.model.QcadooModelMatchers.anyEntity) Entity(com.qcadoo.model.api.Entity) ProductSuffixes(com.qcadoo.mes.technologiesGenerator.customization.product.domain.ProductSuffixes) TechnologyId(com.qcadoo.mes.technologies.domain.TechnologyId) ProductNameSuffix(com.qcadoo.mes.technologiesGenerator.customization.product.domain.ProductNameSuffix) Either(com.qcadoo.commons.functional.Either) ProductNumberSuffix(com.qcadoo.mes.technologiesGenerator.customization.product.domain.ProductNumberSuffix) GeneratorSettings(com.qcadoo.mes.technologiesGenerator.GeneratorSettings) Test(org.junit.Test)

Aggregations

Either (com.qcadoo.commons.functional.Either)1 TechnologyId (com.qcadoo.mes.technologies.domain.TechnologyId)1 GeneratorSettings (com.qcadoo.mes.technologiesGenerator.GeneratorSettings)1 ProductNameSuffix (com.qcadoo.mes.technologiesGenerator.customization.product.domain.ProductNameSuffix)1 ProductNumberSuffix (com.qcadoo.mes.technologiesGenerator.customization.product.domain.ProductNumberSuffix)1 ProductSuffixes (com.qcadoo.mes.technologiesGenerator.customization.product.domain.ProductSuffixes)1 Entity (com.qcadoo.model.api.Entity)1 QcadooModelMatchers.anyEntity (com.qcadoo.testing.model.QcadooModelMatchers.anyEntity)1 Test (org.junit.Test)1