use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyProductsCustomizerTest method shouldFailDueToMainOutputProductComponentValidationErrors.
@Test
public final void shouldFailDueToMainOutputProductComponentValidationErrors() {
// given
Entity technology = mockEntity(TECH_ID, true);
stubTechnologyLookup(technology);
Long mainOpocId = 100L;
Entity mainOutputProductComponent = mockOutputComponent(mainOpocId, false, EntityTestUtils.mockEntity());
stubMainOutputProductComponentLookup(mainOutputProductComponent);
// when
Either<String, TechnologyId> result = technologyProductsCustomizer.customize(technologyId, mainProduct, newProduct, generatorSettings);
// then
Assert.assertTrue(result.isLeft());
Assert.assertEquals(productComponentValidationErrorMessage(mainOutputProductComponent), result.getLeft());
}
use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyProductsCustomizerTest method shouldCustomize.
@Test
@Ignore
public final void shouldCustomize() {
// given
Entity technology = mockEntity(TECH_ID, true);
stubTechnologyLookup(technology);
Long mainOpocId = 100L;
Entity mainOutputProductComponent = mockEntity(mainOpocId, true);
stubMainOutputProductComponentLookup(mainOutputProductComponent);
Entity customizedOpocProd = mockEntity(1101L, true);
Entity opoc = mockOutputComponent(300L, true, customizedOpocProd);
stubOutputComponents(opoc);
Entity customizedOpicProd = mockEntity(2101L, true);
Entity opic = mockInputComponent(400L, true, customizedOpicProd);
stubInputComponents(opic);
// when
Either<String, TechnologyId> result = technologyProductsCustomizer.customize(technologyId, mainProduct, newProduct, generatorSettings);
// then
Assert.assertTrue(result.isRight());
Assert.assertEquals(technologyId, result.getRight());
verify(technology).setField(TechnologyFields.PRODUCT, newProduct);
verify(opic).setField(OperationProductInComponentFields.PRODUCT, customizedOpicProd);
verify(opoc).setField(OperationProductOutComponentFields.PRODUCT, customizedOpocProd);
verify(mainOutputProductComponent).setField(OperationProductOutComponentFields.PRODUCT, newProduct);
}
use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologyProductsCustomizerTest method shouldFailDueToTechnologyValidationErrors.
@Test
public final void shouldFailDueToTechnologyValidationErrors() {
// given
Entity technology = mockEntity(TECH_ID, true, mockEntity(TECH_ID, false));
stubTechnologyLookup(technology);
// when
Either<String, TechnologyId> result = technologyProductsCustomizer.customize(technologyId, mainProduct, newProduct, generatorSettings);
// then
Assert.assertTrue(result.isLeft());
Assert.assertEquals("Validation error while customizing technology product.", result.getLeft());
}
use of com.qcadoo.mes.technologies.domain.TechnologyId in project mes by qcadoo.
the class TechnologiesGeneratorForProductsService method generateTechnologyNode.
private void generateTechnologyNode(Entity node, Entity product, Entity context) {
try {
Optional<Either<String, TechnologyId>> customizedTechId = Optional.ofNullable(product).flatMap(mainProduct -> Optional.ofNullable(node.getId()).flatMap(nodeId -> customize(nodeId, mainProduct, GeneratorSettings.from(context, parameterService.getParameter()), true)));
customizedTechId.ifPresent(cti -> {
if (cti.isRight()) {
TechnologyId technologyId = cti.getRight();
technologyCustomizer.addCustomizedProductToQualityCard(technologyId);
}
});
} catch (Exception e) {
if (LOG.isWarnEnabled()) {
LOG.warn("Cannot perform technology customization due to unexpected error", e);
}
}
}
Aggregations