if (FileImport.State.FAILED.equals(fileImport.getState())) { if (logger.isTraceEnabled()) { logger.trace("\n\nFailed to completely write entities, skipping second phase. File: {}\n", if (FileImport.State.FAILED.equals(fileImport.getState())) { if (logger.isDebugEnabled()) { logger.debug("\n\nparseEntitiesAndConnectionsFromJson(): failed to completely write entities\n"); if (FileImport.State.FAILED.equals(fileImport.getState())) { if (logger.isDebugEnabled()) { logger.debug("\n\nFailed to completely write connections and dictionaries. File: {}\n",
FileImport fi = (FileImport) itr.next(); switch (fi.getState()) { case FAILED: // failed, but we may not be complete so continue checking failCount++; default: // not something we recognize as complete, short circuit if (logger.isDebugEnabled()) { logger.debug("not done yet, bail out... {}", fi.getState().toString());
@Test public void explicitFail() throws Exception { final EntityManagerFactory emf = mock( EntityManagerFactory.class ); final EntityManager em = mock( EntityManager.class ); when( emf.getEntityManager( emf.getManagementAppId() ) ).thenReturn( em ); final UUID importFileId = UUIDGenerator.newTimeUUID(); final FileImport fileImport = new FileImport(); fileImport.setUuid( importFileId ); when( em.get( importFileId, FileImport.class ) ).thenReturn( fileImport ); final FileImportTracker fileImportTracker = new FileImportTracker( emf, fileImport, 1000 ); final long expectedCount = 100; for ( long i = 0; i < expectedCount; i++ ) { fileImportTracker.entityWritten(); } fileImportTracker.fatal( "Something bad happened" ); ArgumentCaptor<FileImport> savedFileImport = ArgumentCaptor.forClass( FileImport.class ); verify( em ).update( savedFileImport.capture() ); final FileImport updated = savedFileImport.getValue(); assertSame( "Same instance should be updated", fileImport, updated ); assertEquals( "Same count expected", expectedCount, updated.getImportedEntityCount() ); assertEquals( "Fail count is 0", 0, updated.getFailedEntityCount() ); assertEquals( "Correct expected message", "Something bad happened", updated.getErrorMessage() ); assertEquals( "Expected failed state", FileImport.State.FAILED, updated.getState() ); }