@Test public void testPrice() throws Exception { processFile(productId, "base_product-", new ProductContent()); TestUtils.disableFileAnalyzer(""); try { final ProductModel product = processFile( productId, "price-", new FileContent() { @Override public void writeContent(final PrintWriter writer) throws IOException { writer.print("1231"); writer.print(SEPARATOR); writer.println("EUR"); } }); Assert.assertEquals(1, product.getEurope1Prices().size()); final PriceRowModel prize = product.getEurope1Prices().iterator().next(); Assert.assertEquals("EUR", prize.getCurrency().getIsocode()); Assert.assertEquals(Double.valueOf(1231), prize.getPrice()); Assert.assertFalse(prize.getNet().booleanValue()); Assert.assertEquals("pieces", prize.getUnit().getCode()); Assert.assertEquals(Integer.valueOf(1), prize.getUnitFactor()); Assert.assertEquals(Long.valueOf(1), prize.getMinqtd()); Assert.assertEquals(sequenceId, prize.getSequenceId()); Assert.assertEquals("Staged", prize.getCatalogVersion().getVersion()); Assert.assertEquals("apparelProductCatalog", prize.getCatalogVersion().getCatalog().getId()); } finally { TestUtils.enableFileAnalyzer(); } }
@Test public void testErrorCode() throws InterruptedException { setResultForAction("test.checkOrderAction", Action.ERROR_RETURN_CODE); try { final BusinessProcessModel process = createProcess("order-process-test"); TestUtils.disableFileAnalyzer(400); assertStep(process, "checkOrder"); } finally { setResultForAction("test.checkOrderAction", "OK"); TestUtils.enableFileAnalyzer(); } }
@Test public void testErrorInProcess() throws InterruptedException { setResultForAction("test.reserveOrderAmountAction", Action.ERROR_RETURN_CODE); final BusinessProcessModel process = createProcess("order-process-test"); assertStep(process, "checkOrder"); assertStep(process, "checkAuthorizeOrderPayment"); TestUtils.disableFileAnalyzer(400); try { assertStep(process, "reserveAmount"); } finally { TestUtils.enableFileAnalyzer(); } Thread.sleep(1000); modelService.refresh(process); assertEquals("Process state", ProcessState.ERROR, process.getProcessState()); }
@Test public void testIfErrorDuringPerformance() { // given Mockito.when(mockSolrQueryStatisticsAggregator.aggregate()).thenThrow(new RuntimeException()); solrQueryStatisticsCollectorJob.setSolrQueryStatisticsAggregator( mockSolrQueryStatisticsAggregator); TestUtils.disableFileAnalyzer("test for an error during job execution"); // when final PerformResult perform = solrQueryStatisticsCollectorJob.perform(null); TestUtils.enableFileAnalyzer(); // then org.fest.assertions.Assertions.assertThat(perform.getResult()).isEqualTo(CronJobResult.ERROR); org.fest.assertions.Assertions.assertThat(perform.getStatus()) .isEqualTo(CronJobStatus.FINISHED); final SearchResult<SolrQueryAggregatedStatsModel> result = flexibleSearchService.search("SELECT {PK} FROM {SolrQueryAggregatedStats}"); org.fest.assertions.Assertions.assertThat(result.getResult()).isEmpty(); }
private void internalImportByConfigWithError(final boolean failOnError) { try { TestUtils.disableFileAnalyzer(); final ImpExResource mediaRes = new StreamBasedImpExResource( new ByteArrayInputStream( "UPDATE Language;isocode[unique=true];active\n;test;true".getBytes()), CSVConstants.HYBRIS_ENCODING); final ImportConfig config = new ImportConfig(); config.setScript(mediaRes); config.setFailOnError(failOnError); final ImportResult result = importService.importData(config); assertNotNull(result); assertFalse(result.isSuccessful()); assertTrue(result.isError()); assertTrue(result.hasUnresolvedLines()); assertNotNull(result.getUnresolvedLines()); assertTrue(result.isFinished()); } finally { TestUtils.enableFileAnalyzer(); } }