use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyCustomizerTest method shouldCreateCustomizedTechnologyWithMainProduct.
@Test
public final void shouldCreateCustomizedTechnologyWithMainProduct() {
// 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, null, nodeProduct);
stubIsValid(node, true);
stubNodeSearchResult(node);
Entity mainOpoc = mockEntity();
stubIsValid(mainOpoc, true);
String generatedTechNumber = "generatedTechNumber";
String generatedTechName = "generated tech name";
stubTechNameAndNumberGenerator(mainProduct, 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, mainProduct, generatorSettings);
verify(technologyOperationProductsCustomizer, never()).prepareMainTechnologyProduct(anyEntity(), anyEntity());
verify(technologyNameAndNumberGenerator).generateName(mainProduct);
verify(technologyNameAndNumberGenerator).generateNumber(mainProduct);
verify(technologyCopy).setField(TechnologyFields.NUMBER, generatedTechNumber);
verify(technologyCopy).setField(TechnologyFields.NAME, generatedTechName);
verify(node).setField(GeneratorTreeNodeFields.PRODUCT_TECHNOLOGY, 2L);
verify(productCustomizer, never()).findOrCreate(anyEntity(), anyEntity(), any(ProductSuffixes.class), any(GeneratorSettings.class));
}
use of com.qcadoo.mes.technologies.domain.TechnologyId 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));
}
use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyCustomizerTest method shouldCreateCustomizedTechnologyWithMainProductEvenIfTechnologyOutputProductIsNotAProductsFamily.
@Test
public final void shouldCreateCustomizedTechnologyWithMainProductEvenIfTechnologyOutputProductIsNotAProductsFamily() {
// given
Entity technologyCopy = mockTechnology(2L, true, null);
Entity technology = mockTechnology(1L, true, technologyCopy);
stubIsValid(technology, true);
Entity nodeProduct = mockProduct(ProductFamilyElementType.PARTICULAR_PRODUCT);
Entity node = mockNodeEntity(technology, TechnologyStructureNodeType.COMPONENT, null, nodeProduct);
stubIsValid(node, true);
stubNodeSearchResult(node);
Entity mainOpoc = mockEntity();
stubIsValid(mainOpoc, true);
String generatedTechNumber = "generatedTechNumber";
String generatedTechName = "generated tech name";
stubTechNameAndNumberGenerator(mainProduct, 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, mainProduct, generatorSettings);
verify(technologyOperationProductsCustomizer, never()).prepareMainTechnologyProduct(anyEntity(), anyEntity());
verify(technologyNameAndNumberGenerator).generateName(mainProduct);
verify(technologyNameAndNumberGenerator).generateNumber(mainProduct);
verify(technologyCopy).setField(TechnologyFields.NUMBER, generatedTechNumber);
verify(technologyCopy).setField(TechnologyFields.NAME, generatedTechName);
verify(node).setField(GeneratorTreeNodeFields.PRODUCT_TECHNOLOGY, 2L);
verify(productCustomizer, never()).findOrCreate(anyEntity(), anyEntity(), any(ProductSuffixes.class), any(GeneratorSettings.class));
}
use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyCustomizerTest method shouldCreateCustomizedTechnologyWithAlteredMainOutputProduct2.
@Test
public final void shouldCreateCustomizedTechnologyWithAlteredMainOutputProduct2() {
// given
given(generatorSettings.shouldCreateAndSwitchProducts()).willReturn(false);
Entity technologyCopy = mockTechnology(2L, true, null);
Entity technology = mockTechnology(1L, true, technologyCopy);
stubIsValid(technology, true);
Entity nodeProduct = mockProduct(ProductFamilyElementType.PARTICULAR_PRODUCT);
stubIsValid(nodeProduct, true);
Entity node = mockNodeEntity(technology, TechnologyStructureNodeType.COMPONENT, null, nodeProduct);
stubIsValid(node, true);
stubNodeSearchResult(node);
String generatedTechNumber = "generatedTechNumber";
String generatedTechName = "generated tech name";
stubTechNameAndNumberGenerator(mainProduct, 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, never()).customize(any(TechnologyId.class), anyEntity(), anyEntity(), any(GeneratorSettings.class));
verify(technologyOperationProductsCustomizer).prepareMainTechnologyProduct(technologyCopy, mainProduct);
verify(technologyNameAndNumberGenerator).generateName(mainProduct);
verify(technologyNameAndNumberGenerator).generateNumber(mainProduct);
verify(technologyCopy).setField(TechnologyFields.NUMBER, generatedTechNumber);
verify(technologyCopy).setField(TechnologyFields.NAME, generatedTechName);
verify(node).setField(GeneratorTreeNodeFields.PRODUCT_TECHNOLOGY, 2L);
verify(productCustomizer, never()).findOrCreate(anyEntity(), anyEntity(), any(ProductSuffixes.class), any(GeneratorSettings.class));
}
use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyCustomizerTest method shouldCreateCustomizedTechnologyWithoutAlteringMainOutputProduct.
@Test
public final void shouldCreateCustomizedTechnologyWithoutAlteringMainOutputProduct() {
// given
given(generatorSettings.shouldCreateAndSwitchProducts()).willReturn(true);
Entity technologyCopy = mockTechnology(2L, true, null);
Entity technology = mockTechnology(1L, true, technologyCopy);
stubIsValid(technology, true);
Entity nodeProduct = mockProduct(ProductFamilyElementType.PARTICULAR_PRODUCT);
stubIsValid(nodeProduct, true);
Entity node = mockNodeEntity(technology, TechnologyStructureNodeType.COMPONENT, mockEntity(), nodeProduct);
stubBelongsToField(node, GeneratorTreeNodeFields.PRODUCT, nodeProduct);
stubIsValid(node, true);
stubNodeSearchResult(node);
String generatedTechNumber = "generatedTechNumber";
String generatedTechName = "generated tech name";
stubTechNameAndNumberGenerator(nodeProduct, 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, nodeProduct, generatorSettings);
verify(technologyOperationProductsCustomizer, never()).prepareMainTechnologyProduct(anyEntity(), anyEntity());
verify(technologyNameAndNumberGenerator).generateName(nodeProduct);
verify(technologyNameAndNumberGenerator).generateNumber(nodeProduct);
verify(technologyCopy).setField(TechnologyFields.NUMBER, generatedTechNumber);
verify(technologyCopy).setField(TechnologyFields.NAME, generatedTechName);
verify(node).setField(GeneratorTreeNodeFields.PRODUCT_TECHNOLOGY, 2L);
verify(productCustomizer, never()).findOrCreate(anyEntity(), anyEntity(), any(ProductSuffixes.class), any(GeneratorSettings.class));
}
Aggregations