@Test public void testIsDuplicateKeyErrorOnMongoBulkWriteException() { MongoBulkWriteException mongoWriteException = mock(MongoBulkWriteException.class); BulkWriteError writeErrorMock = mock(BulkWriteError.class); when(writeErrorMock.getCategory()).thenReturn(ErrorCategory.DUPLICATE_KEY); when(mongoWriteException.getWriteErrors()).thenReturn(Lists.newArrayList(writeErrorMock)); assertThat(DbRequestHelper.isDuplicateKeyError(mongoWriteException)).isTrue(); when(writeErrorMock.getCategory()).thenReturn(ErrorCategory.EXECUTION_TIMEOUT); assertThat(DbRequestHelper.isDuplicateKeyError(mongoWriteException)).isFalse(); }
public static boolean isDuplicateKeyError(Exception e) { if (e instanceof MongoBulkWriteException || e instanceof MongoWriteException) { return isDuplicateKeyException(e); } if (e instanceof DatabaseException && (e.getCause() instanceof MongoBulkWriteException || e.getCause() instanceof MongoWriteException)) { return isDuplicateKeyException(e.getCause()); } Throwable d = e.getCause(); if (d instanceof DatabaseException && (d.getCause() instanceof MongoBulkWriteException || d.getCause() instanceof MongoWriteException)) { return isDuplicateKeyException(e.getCause()); } return false; }
DbRequestHelper { public static boolean isDuplicateKeyError(Exception e) { if (e instanceof MongoBulkWriteException || e instanceof MongoWriteException) { return isDuplicateKeyException(e); } if (e instanceof DatabaseException && (e.getCause() instanceof MongoBulkWriteException || e.getCause() instanceof MongoWriteException)) { return isDuplicateKeyException(e.getCause()); } Throwable d = e.getCause(); if (d instanceof DatabaseException && (d.getCause() instanceof MongoBulkWriteException || d.getCause() instanceof MongoWriteException)) { return isDuplicateKeyException(e.getCause()); } return false; } }
DbRequestHelper { public static boolean isDuplicateKeyError(Exception e) { if (e instanceof MongoBulkWriteException || e instanceof MongoWriteException) { return isDuplicateKeyException(e); } if (e instanceof DatabaseException && (e.getCause() instanceof MongoBulkWriteException || e.getCause() instanceof MongoWriteException)) { return isDuplicateKeyException(e.getCause()); } Throwable d = e.getCause(); if (d instanceof DatabaseException && (d.getCause() instanceof MongoBulkWriteException || d.getCause() instanceof MongoWriteException)) { return isDuplicateKeyException(e.getCause()); } return false; } private  DbRequestHelper(); }
DbRequestHelper { public static boolean isDuplicateKeyError(Exception e) { if (e instanceof MongoBulkWriteException || e instanceof MongoWriteException) { return isDuplicateKeyException(e); } if (e instanceof DatabaseException && (e.getCause() instanceof MongoBulkWriteException || e.getCause() instanceof MongoWriteException)) { return isDuplicateKeyException(e.getCause()); } Throwable d = e.getCause(); if (d instanceof DatabaseException && (d.getCause() instanceof MongoBulkWriteException || d.getCause() instanceof MongoWriteException)) { return isDuplicateKeyException(e.getCause()); } return false; } private  DbRequestHelper(); static boolean isDuplicateKeyError(Exception e); @SuppressWarnings("unchecked") static MongoCursor<VitamDocument<?>> selectMongoDbExecuteThroughFakeMongoCursor(
        VitamCollection collection, RequestParserSingle parser, List<String> list, List<Float> scores); }
DbRequestHelper { public static boolean isDuplicateKeyError(Exception e) { if (e instanceof MongoBulkWriteException || e instanceof MongoWriteException) { return isDuplicateKeyException(e); } if (e instanceof DatabaseException && (e.getCause() instanceof MongoBulkWriteException || e.getCause() instanceof MongoWriteException)) { return isDuplicateKeyException(e.getCause()); } Throwable d = e.getCause(); if (d instanceof DatabaseException && (d.getCause() instanceof MongoBulkWriteException || d.getCause() instanceof MongoWriteException)) { return isDuplicateKeyException(e.getCause()); } return false; } private  DbRequestHelper(); static boolean isDuplicateKeyError(Exception e); @SuppressWarnings("unchecked") static MongoCursor<VitamDocument<?>> selectMongoDbExecuteThroughFakeMongoCursor(
        VitamCollection collection, RequestParserSingle parser, List<String> list, List<Float> scores); static final String CONSISTENCY_ERROR_THE_DOCUMENT_GUID_S_IN_ES_IS_NOT_IN_MONGO_DB_ANYMORE_TENANT_S_REQUEST_ID_S; }