target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void callsBeatBoxPlayOnButtonClicked() { mSubject.onButtonClicked(); verify(mBeatBox).play(mSound); } | public void onButtonClicked() { mBeatBox.play(mSound); } | SoundViewModel extends BaseObservable { public void onButtonClicked() { mBeatBox.play(mSound); } } | SoundViewModel extends BaseObservable { public void onButtonClicked() { mBeatBox.play(mSound); } SoundViewModel(BeatBox beatBox); } | SoundViewModel extends BaseObservable { public void onButtonClicked() { mBeatBox.play(mSound); } SoundViewModel(BeatBox beatBox); @Bindable String getTitle(); Sound getSound(); void setSound(Sound sound); void onButtonClicked(); } | SoundViewModel extends BaseObservable { public void onButtonClicked() { mBeatBox.play(mSound); } SoundViewModel(BeatBox beatBox); @Bindable String getTitle(); Sound getSound(); void setSound(Sound sound); void onButtonClicked(); } |
@Test public void exposesSoundNameAsTitle() { assertThat(mSubject.getTitle(), is(mSound.getName())); } | @Bindable public String getTitle() { return mSound.getName(); } | SoundViewModel extends BaseObservable { @Bindable public String getTitle() { return mSound.getName(); } } | SoundViewModel extends BaseObservable { @Bindable public String getTitle() { return mSound.getName(); } SoundViewModel(BeatBox beatBox); } | SoundViewModel extends BaseObservable { @Bindable public String getTitle() { return mSound.getName(); } SoundViewModel(BeatBox beatBox); @Bindable String getTitle(); Sound getSound(); void setSound(Sound sound); void onButtonClicked(); } | SoundViewModel extends BaseObservable { @Bindable public String getTitle() { return mSound.getName(); } SoundViewModel(BeatBox beatBox); @Bindable String getTitle(); Sound getSound(); void setSound(Sound sound); void onButtonClicked(); } |
@Test public void testCreateBeer() { assertEquals(0, service.getBeersCount()); Beer myBeer = service.createBeer("mine", 0); assertEquals(1, service.getBeersCount()); Iterable<Beer> founds = service.getAllBeers(); Beer mine = founds.iterator().next(); assertEquals(myBeer.getName(), mine.getName()); } | public Beer createBeer(final String name, final int alcoholPercentage) { return beerRepository.save(new Beer(name, alcoholPercentage)); } | PubService { public Beer createBeer(final String name, final int alcoholPercentage) { return beerRepository.save(new Beer(name, alcoholPercentage)); } } | PubService { public Beer createBeer(final String name, final int alcoholPercentage) { return beerRepository.save(new Beer(name, alcoholPercentage)); } } | PubService { public Beer createBeer(final String name, final int alcoholPercentage) { return beerRepository.save(new Beer(name, alcoholPercentage)); } long getBeersCount(); Beer createBeer(final String name, final int alcoholPercentage); BrewingCompany createBrewingCompany(final String name); Iterable<Beer> getAllBeers(); Beer findBeerById(final long id); Beer findBeerByName(final String name); Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage); Collection<Beer> populateData(); } | PubService { public Beer createBeer(final String name, final int alcoholPercentage) { return beerRepository.save(new Beer(name, alcoholPercentage)); } long getBeersCount(); Beer createBeer(final String name, final int alcoholPercentage); BrewingCompany createBrewingCompany(final String name); Iterable<Beer> getAllBeers(); Beer findBeerById(final long id); Beer findBeerByName(final String name); Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage); Collection<Beer> populateData(); } |
@Test public void testFindBeerById() { service.populateData(); for (Beer beer : service.getAllBeers()) { Beer foundBeer = service.findBeerById(beer.getId()); assertNotNull(foundBeer); } } | public Beer findBeerById(final long id) { return beerRepository.findOne(id); } | PubService { public Beer findBeerById(final long id) { return beerRepository.findOne(id); } } | PubService { public Beer findBeerById(final long id) { return beerRepository.findOne(id); } } | PubService { public Beer findBeerById(final long id) { return beerRepository.findOne(id); } long getBeersCount(); Beer createBeer(final String name, final int alcoholPercentage); BrewingCompany createBrewingCompany(final String name); Iterable<Beer> getAllBeers(); Beer findBeerById(final long id); Beer findBeerByName(final String name); Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage); Collection<Beer> populateData(); } | PubService { public Beer findBeerById(final long id) { return beerRepository.findOne(id); } long getBeersCount(); Beer createBeer(final String name, final int alcoholPercentage); BrewingCompany createBrewingCompany(final String name); Iterable<Beer> getAllBeers(); Beer findBeerById(final long id); Beer findBeerByName(final String name); Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage); Collection<Beer> populateData(); } |
@Test public void testGetAllBeers() { Collection<Beer> madeBeers = service.populateData(); Iterable<Beer> foundBeers = service.getAllBeers(); int founds = 0; for (Beer foundBeer : foundBeers) { assertTrue(madeBeers.contains(foundBeer)); founds++; } assertEquals(madeBeers.size(), founds); } | public Iterable<Beer> getAllBeers() { return beerRepository.findAll(); } | PubService { public Iterable<Beer> getAllBeers() { return beerRepository.findAll(); } } | PubService { public Iterable<Beer> getAllBeers() { return beerRepository.findAll(); } } | PubService { public Iterable<Beer> getAllBeers() { return beerRepository.findAll(); } long getBeersCount(); Beer createBeer(final String name, final int alcoholPercentage); BrewingCompany createBrewingCompany(final String name); Iterable<Beer> getAllBeers(); Beer findBeerById(final long id); Beer findBeerByName(final String name); Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage); Collection<Beer> populateData(); } | PubService { public Iterable<Beer> getAllBeers() { return beerRepository.findAll(); } long getBeersCount(); Beer createBeer(final String name, final int alcoholPercentage); BrewingCompany createBrewingCompany(final String name); Iterable<Beer> getAllBeers(); Beer findBeerById(final long id); Beer findBeerByName(final String name); Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage); Collection<Beer> populateData(); } |
@Test public void testFindBeerByAlcoholPercentage() { service.populateData(); for (Beer beer : service.findBeerByAlcoholPercentage(7)) { assertThat( beer.getName(), is(anyOf(containsString("Chimay Rood"), containsString("Florival Bruin")))); } } | public Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage) { return beerRepository.findAllByPropertyValue("alcoholPercentage", alcoholPercentage); } | PubService { public Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage) { return beerRepository.findAllByPropertyValue("alcoholPercentage", alcoholPercentage); } } | PubService { public Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage) { return beerRepository.findAllByPropertyValue("alcoholPercentage", alcoholPercentage); } } | PubService { public Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage) { return beerRepository.findAllByPropertyValue("alcoholPercentage", alcoholPercentage); } long getBeersCount(); Beer createBeer(final String name, final int alcoholPercentage); BrewingCompany createBrewingCompany(final String name); Iterable<Beer> getAllBeers(); Beer findBeerById(final long id); Beer findBeerByName(final String name); Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage); Collection<Beer> populateData(); } | PubService { public Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage) { return beerRepository.findAllByPropertyValue("alcoholPercentage", alcoholPercentage); } long getBeersCount(); Beer createBeer(final String name, final int alcoholPercentage); BrewingCompany createBrewingCompany(final String name); Iterable<Beer> getAllBeers(); Beer findBeerById(final long id); Beer findBeerByName(final String name); Iterable<Beer> findBeerByAlcoholPercentage(final int alcoholPercentage); Collection<Beer> populateData(); } |
@Test public void testEqualsAndHashCode() { assertSoftly( softly -> { SimpleGlobPattern equalPattern = SimpleGlobPattern.compile( patternString ); softly.assertThat( pattern ) .isEqualTo( equalPattern ) .isNotEqualTo( SimpleGlobPattern.compile( patternString + "a" ) ) .isNotEqualTo( SimpleGlobPattern.compile( "a" + patternString ) ) .isNotEqualTo( SimpleGlobPattern.compile( patternString + "a*" ) ) .isNotEqualTo( SimpleGlobPattern.compile( "a*" + patternString ) ); softly.assertThat( pattern.hashCode() == equalPattern.hashCode() ) .as( "Hashcode of .compile(" + patternString + ") is always the same" ) .isTrue(); } ); } | public static SimpleGlobPattern compile(String patternString) { SimpleGlobPattern pattern = EmptyGlobPattern.INSTANCE; int endIndexInclusive = patternString.length() - 1; while ( endIndexInclusive >= 0 ) { int lastWildcardIndex = patternString.lastIndexOf( WILDCARD_MANY, endIndexInclusive ); if ( lastWildcardIndex < endIndexInclusive ) { pattern = pattern.prependLiteral( patternString.substring( lastWildcardIndex + 1, endIndexInclusive + 1 ) ); } if ( 0 <= lastWildcardIndex ) { pattern = pattern.prependMany(); } endIndexInclusive = lastWildcardIndex - 1; } return pattern; } | SimpleGlobPattern { public static SimpleGlobPattern compile(String patternString) { SimpleGlobPattern pattern = EmptyGlobPattern.INSTANCE; int endIndexInclusive = patternString.length() - 1; while ( endIndexInclusive >= 0 ) { int lastWildcardIndex = patternString.lastIndexOf( WILDCARD_MANY, endIndexInclusive ); if ( lastWildcardIndex < endIndexInclusive ) { pattern = pattern.prependLiteral( patternString.substring( lastWildcardIndex + 1, endIndexInclusive + 1 ) ); } if ( 0 <= lastWildcardIndex ) { pattern = pattern.prependMany(); } endIndexInclusive = lastWildcardIndex - 1; } return pattern; } } | SimpleGlobPattern { public static SimpleGlobPattern compile(String patternString) { SimpleGlobPattern pattern = EmptyGlobPattern.INSTANCE; int endIndexInclusive = patternString.length() - 1; while ( endIndexInclusive >= 0 ) { int lastWildcardIndex = patternString.lastIndexOf( WILDCARD_MANY, endIndexInclusive ); if ( lastWildcardIndex < endIndexInclusive ) { pattern = pattern.prependLiteral( patternString.substring( lastWildcardIndex + 1, endIndexInclusive + 1 ) ); } if ( 0 <= lastWildcardIndex ) { pattern = pattern.prependMany(); } endIndexInclusive = lastWildcardIndex - 1; } return pattern; } private SimpleGlobPattern(); } | SimpleGlobPattern { public static SimpleGlobPattern compile(String patternString) { SimpleGlobPattern pattern = EmptyGlobPattern.INSTANCE; int endIndexInclusive = patternString.length() - 1; while ( endIndexInclusive >= 0 ) { int lastWildcardIndex = patternString.lastIndexOf( WILDCARD_MANY, endIndexInclusive ); if ( lastWildcardIndex < endIndexInclusive ) { pattern = pattern.prependLiteral( patternString.substring( lastWildcardIndex + 1, endIndexInclusive + 1 ) ); } if ( 0 <= lastWildcardIndex ) { pattern = pattern.prependMany(); } endIndexInclusive = lastWildcardIndex - 1; } return pattern; } private SimpleGlobPattern(); static SimpleGlobPattern compile(String patternString); boolean matches(String candidate); SimpleGlobPattern prependLiteral(String literal); SimpleGlobPattern prependMany(); Optional<String> toLiteral(); abstract String toPatternString(); } | SimpleGlobPattern { public static SimpleGlobPattern compile(String patternString) { SimpleGlobPattern pattern = EmptyGlobPattern.INSTANCE; int endIndexInclusive = patternString.length() - 1; while ( endIndexInclusive >= 0 ) { int lastWildcardIndex = patternString.lastIndexOf( WILDCARD_MANY, endIndexInclusive ); if ( lastWildcardIndex < endIndexInclusive ) { pattern = pattern.prependLiteral( patternString.substring( lastWildcardIndex + 1, endIndexInclusive + 1 ) ); } if ( 0 <= lastWildcardIndex ) { pattern = pattern.prependMany(); } endIndexInclusive = lastWildcardIndex - 1; } return pattern; } private SimpleGlobPattern(); static SimpleGlobPattern compile(String patternString); boolean matches(String candidate); SimpleGlobPattern prependLiteral(String literal); SimpleGlobPattern prependMany(); Optional<String> toLiteral(); abstract String toPatternString(); } |
@Test public void failure_work() { RuntimeException work1Exception = new RuntimeException( "work1" ); Long work2Result = 41L; Long work3Result = 43L; ArgumentCaptor<CompletableFuture<Long>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work3FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; LuceneIndexIndexingPlanExecution<StubEntityReference> execution = new LuceneIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, commitStrategy, refreshStrategy, workMocks( 3 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work2FutureCaptor.getValue().complete( work2Result ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work1FutureCaptor.getValue().completeExceptionally( work1Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work3FutureCaptor.getValue().complete( work3Result ); if ( DocumentCommitStrategy.FORCE.equals( commitStrategy ) ) { verify( orchestratorMock ).forceCommitInCurrentThread(); } if ( DocumentRefreshStrategy.FORCE.equals( refreshStrategy ) ) { verify( orchestratorMock ).forceRefreshInCurrentThread(); } verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).containsSame( work1Exception ); softly.assertThat( report.failingEntityReferences() ) .containsExactlyInAnyOrder( entityReference( 0 ) ); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } |
@Test public void failure_multipleWorks() { RuntimeException work1Exception = new RuntimeException( "work1" ); Long work2Result = 41L; RuntimeException work3Exception = new RuntimeException( "work3" ); Long work4Result = 44L; ArgumentCaptor<CompletableFuture<Long>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work3FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work4FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; LuceneIndexIndexingPlanExecution<StubEntityReference> execution = new LuceneIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, commitStrategy, refreshStrategy, workMocks( 4 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verify( orchestratorMock ).submit( work4FutureCaptor.capture(), eq( workMocks.get( 3 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work2FutureCaptor.getValue().complete( work2Result ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work1FutureCaptor.getValue().completeExceptionally( work1Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work3FutureCaptor.getValue().completeExceptionally( work3Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work4FutureCaptor.getValue().complete( work4Result ); if ( DocumentCommitStrategy.FORCE.equals( commitStrategy ) ) { verify( orchestratorMock ).forceCommitInCurrentThread(); } if ( DocumentRefreshStrategy.FORCE.equals( refreshStrategy ) ) { verify( orchestratorMock ).forceRefreshInCurrentThread(); } verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).containsSame( work1Exception ); assertThat( work1Exception ).hasSuppressedException( work3Exception ); softly.assertThat( report.failingEntityReferences() ) .containsExactlyInAnyOrder( entityReference( 0 ), entityReference( 2 ) ); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } |
@Test @TestForIssue(jiraKey = "HSEARCH-3851") public void failure_multipleWorksAndCreateEntityReference() { RuntimeException work1Exception = new RuntimeException( "work1" ); Long work2Result = 41L; RuntimeException work3Exception = new RuntimeException( "work3" ); Long work4Result = 44L; ArgumentCaptor<CompletableFuture<Long>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work3FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work4FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; LuceneIndexIndexingPlanExecution<StubEntityReference> execution = new LuceneIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, commitStrategy, refreshStrategy, workMocks( 4 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verify( orchestratorMock ).submit( work4FutureCaptor.capture(), eq( workMocks.get( 3 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work2FutureCaptor.getValue().complete( work2Result ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work1FutureCaptor.getValue().completeExceptionally( work1Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work3FutureCaptor.getValue().completeExceptionally( work3Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); RuntimeException entityReferenceFactoryException = new RuntimeException( "EntityReferenceFactory message" ); when( entityReferenceFactoryMock.createEntityReference( TYPE_NAME, 0 ) ) .thenThrow( entityReferenceFactoryException ); work4FutureCaptor.getValue().complete( work4Result ); if ( DocumentCommitStrategy.FORCE.equals( commitStrategy ) ) { verify( orchestratorMock ).forceCommitInCurrentThread(); } if ( DocumentRefreshStrategy.FORCE.equals( refreshStrategy ) ) { verify( orchestratorMock ).forceRefreshInCurrentThread(); } verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).containsSame( work1Exception ); softly.assertThat( work1Exception ).hasSuppressedException( entityReferenceFactoryException ); softly.assertThat( report.failingEntityReferences() ) .containsExactly( entityReference( 2 ) ); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } |
@Test public void failure_commit() { assumeTrue( "This test only makes sense when commit is forced", DocumentCommitStrategy.FORCE.equals( commitStrategy ) ); Long work1Result = 42L; Long work2Result = 41L; Long work3Result = 43L; ArgumentCaptor<CompletableFuture<Long>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work3FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; LuceneIndexIndexingPlanExecution<StubEntityReference> execution = new LuceneIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, commitStrategy, refreshStrategy, workMocks( 3 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); work2FutureCaptor.getValue().complete( work2Result ); work1FutureCaptor.getValue().complete( work1Result ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); RuntimeException commitException = new RuntimeException( "Some message" ); doThrow( commitException ).when( orchestratorMock ).forceCommitInCurrentThread(); work3FutureCaptor.getValue().complete( work3Result ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).containsSame( commitException ); softly.assertThat( report.failingEntityReferences() ) .containsExactly( entityReference( 0 ), entityReference( 1 ), entityReference( 2 ) ); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } |
@Test public void failure_refresh() { assumeTrue( "This test only makes sense when refresh is forced", DocumentRefreshStrategy.FORCE.equals( refreshStrategy ) ); Long work1Result = 42L; Long work2Result = 41L; Long work3Result = 43L; ArgumentCaptor<CompletableFuture<Long>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work3FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; LuceneIndexIndexingPlanExecution<StubEntityReference> execution = new LuceneIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, commitStrategy, DocumentRefreshStrategy.FORCE, workMocks( 3 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); work2FutureCaptor.getValue().complete( work2Result ); work1FutureCaptor.getValue().complete( work1Result ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); RuntimeException refreshException = new RuntimeException( "Some message" ); doThrow( refreshException ).when( orchestratorMock ).forceRefreshInCurrentThread(); work3FutureCaptor.getValue().complete( work3Result ); if ( DocumentCommitStrategy.FORCE.equals( commitStrategy ) ) { verify( orchestratorMock ).forceCommitInCurrentThread(); } verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).containsSame( refreshException ); softly.assertThat( report.failingEntityReferences() ) .containsExactly( entityReference( 0 ), entityReference( 1 ), entityReference( 2 ) ); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } |
@Test public void failure_workAndCommit() { assumeTrue( "This test only makes sense when commit is forced", DocumentCommitStrategy.FORCE.equals( commitStrategy ) ); RuntimeException work1Exception = new RuntimeException( "work1" ); Long work2Result = 41L; Long work3Result = 43L; ArgumentCaptor<CompletableFuture<Long>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work3FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; LuceneIndexIndexingPlanExecution<StubEntityReference> execution = new LuceneIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, commitStrategy, refreshStrategy, workMocks( 3 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); work2FutureCaptor.getValue().complete( work2Result ); work1FutureCaptor.getValue().completeExceptionally( work1Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); RuntimeException commitException = new RuntimeException( "Some message" ); doThrow( commitException ).when( orchestratorMock ).forceCommitInCurrentThread(); work3FutureCaptor.getValue().complete( work3Result ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).containsSame( work1Exception ); softly.assertThat( work1Exception ).hasSuppressedException( commitException ); softly.assertThat( report.failingEntityReferences() ) .containsExactly( entityReference( 0 ), entityReference( 1 ), entityReference( 2 ) ); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } |
@Test public void failure_workAndRefresh() { assumeTrue( "This test only makes sense when refresh is forced", DocumentRefreshStrategy.FORCE.equals( refreshStrategy ) ); RuntimeException work1Exception = new RuntimeException( "work1" ); Long work2Result = 41L; Long work3Result = 43L; ArgumentCaptor<CompletableFuture<Long>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Long>> work3FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; LuceneIndexIndexingPlanExecution<StubEntityReference> execution = new LuceneIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, commitStrategy, DocumentRefreshStrategy.FORCE, workMocks( 3 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); work2FutureCaptor.getValue().complete( work2Result ); work1FutureCaptor.getValue().completeExceptionally( work1Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); RuntimeException refreshException = new RuntimeException( "Some message" ); doThrow( refreshException ).when( orchestratorMock ).forceRefreshInCurrentThread(); work3FutureCaptor.getValue().complete( work3Result ); if ( DocumentCommitStrategy.FORCE.equals( commitStrategy ) ) { verify( orchestratorMock ).forceCommitInCurrentThread(); } verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).containsSame( work1Exception ); softly.assertThat( work1Exception ).hasSuppressedException( refreshException ); softly.assertThat( report.failingEntityReferences() ) .containsExactly( entityReference( 0 ), entityReference( 1 ), entityReference( 2 ) ); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } | LuceneIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Long> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } LuceneIndexIndexingPlanExecution(LuceneSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy,
List<SingleDocumentIndexingWork> works); } |
@Test public void testEnableInfoStream() throws Exception { LoggerInfoStream infoStream = new LoggerInfoStream(); ByteBuffersDirectory directory = new ByteBuffersDirectory(); IndexWriterConfig indexWriterConfig = new IndexWriterConfig( new StandardAnalyzer() ); indexWriterConfig.setInfoStream( infoStream ); IndexWriter indexWriter = new IndexWriter( directory, indexWriterConfig ); Document doc = new Document(); doc.add( new StringField( "f1", "value1", Field.Store.YES ) ); indexWriter.addDocument( doc ); indexWriter.commit(); indexWriter.close(); List<LoggingEvent> loggingEvents = testAppender.searchByLoggerAndMessage( LuceneLogCategories.INFOSTREAM_LOGGER_CATEGORY.getName(), "IW:" ); assertFalse( loggingEvents.isEmpty() ); } | @Override public void close() { } | LoggerInfoStream extends InfoStream { @Override public void close() { } } | LoggerInfoStream extends InfoStream { @Override public void close() { } } | LoggerInfoStream extends InfoStream { @Override public void close() { } @Override void message(String component, String message); @Override boolean isEnabled(String component); @Override void close(); } | LoggerInfoStream extends InfoStream { @Override public void close() { } @Override void message(String component, String message); @Override boolean isEnabled(String component); @Override void close(); } |
@Test public void shardKey() { assertThat( LuceneIndexSettings.shardKey( "shardId", "foo.bar" ) ) .isEqualTo( "hibernate.search.backend.shards.shardId.foo.bar" ); assertThat( LuceneIndexSettings.shardKey( "indexName", "shardId", "foo.bar" ) ) .isEqualTo( "hibernate.search.backend.indexes.indexName.shards.shardId.foo.bar" ); assertThat( LuceneIndexSettings.shardKey( null, "shardId", "foo.bar" ) ) .isEqualTo( "hibernate.search.backend.shards.shardId.foo.bar" ); assertThat( LuceneIndexSettings.shardKey( "backendName", "indexName", "shardId", "foo.bar" ) ) .isEqualTo( "hibernate.search.backends.backendName.indexes.indexName.shards.shardId.foo.bar" ); assertThat( LuceneIndexSettings.shardKey( null, "indexName", "shardId", "foo.bar" ) ) .isEqualTo( "hibernate.search.backend.indexes.indexName.shards.shardId.foo.bar" ); assertThat( LuceneIndexSettings.shardKey( "backendName", null, "shardId", "foo.bar" ) ) .isEqualTo( "hibernate.search.backends.backendName.shards.shardId.foo.bar" ); } | public static String shardKey(String shardId, String radical) { return join( ".", EngineSettings.BACKEND, SHARDS, shardId, radical ); } | LuceneIndexSettings { public static String shardKey(String shardId, String radical) { return join( ".", EngineSettings.BACKEND, SHARDS, shardId, radical ); } } | LuceneIndexSettings { public static String shardKey(String shardId, String radical) { return join( ".", EngineSettings.BACKEND, SHARDS, shardId, radical ); } private LuceneIndexSettings(); } | LuceneIndexSettings { public static String shardKey(String shardId, String radical) { return join( ".", EngineSettings.BACKEND, SHARDS, shardId, radical ); } private LuceneIndexSettings(); static String shardKey(String shardId, String radical); static String shardKey(String indexName, String shardId, String radical); static String shardKey(String backendName, String indexName, String shardId, String radical); } | LuceneIndexSettings { public static String shardKey(String shardId, String radical) { return join( ".", EngineSettings.BACKEND, SHARDS, shardId, radical ); } private LuceneIndexSettings(); static String shardKey(String shardId, String radical); static String shardKey(String indexName, String shardId, String radical); static String shardKey(String backendName, String indexName, String shardId, String radical); static final String DIRECTORY_PREFIX; static final String DIRECTORY_TYPE; static final String DIRECTORY_ROOT; static final String DIRECTORY_LOCKING_STRATEGY; static final String DIRECTORY_FILESYSTEM_ACCESS_STRATEGY; static final String IO_PREFIX; static final String IO_STRATEGY; static final String IO_COMMIT_INTERVAL; static final String IO_REFRESH_INTERVAL; static final String IO_WRITER_PREFIX; static final String IO_WRITER_MAX_BUFFERED_DOCS; static final String IO_WRITER_RAM_BUFFER_SIZE; static final String IO_WRITER_INFOSTREAM; static final String IO_MERGE_PREFIX; static final String IO_MERGE_MAX_DOCS; static final String IO_MERGE_FACTOR; static final String IO_MERGE_MIN_SIZE; static final String IO_MERGE_MAX_SIZE; static final String IO_MERGE_MAX_FORCED_SIZE; static final String IO_MERGE_CALIBRATE_BY_DELETES; static final String SHARDING_PREFIX; static final String SHARDING_STRATEGY; static final String SHARDING_NUMBER_OF_SHARDS; static final String SHARDING_SHARD_IDENTIFIERS; static final String SHARDS; static final String INDEXING_PREFIX; static final String INDEXING_QUEUE_COUNT; static final String INDEXING_QUEUE_SIZE; } |
@Test public void forceCommit() { processor.forceCommit(); verify( indexAccessorMock ).commit(); verifyNoOtherIndexInteractionsAndClear(); } | public void forceCommit() { try { indexAccessor.commit(); } catch (RuntimeException e) { indexAccessor.cleanUpAfterFailure( e, "Commit after a set of index works" ); throw e; } } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceCommit() { try { indexAccessor.commit(); } catch (RuntimeException e) { indexAccessor.cleanUpAfterFailure( e, "Commit after a set of index works" ); throw e; } } } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceCommit() { try { indexAccessor.commit(); } catch (RuntimeException e) { indexAccessor.cleanUpAfterFailure( e, "Commit after a set of index works" ); throw e; } } LuceneBatchedWorkProcessor(EventContext eventContext,
IndexAccessor indexAccessor); } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceCommit() { try { indexAccessor.commit(); } catch (RuntimeException e) { indexAccessor.cleanUpAfterFailure( e, "Commit after a set of index works" ); throw e; } } LuceneBatchedWorkProcessor(EventContext eventContext,
IndexAccessor indexAccessor); @Override void beginBatch(); @Override CompletableFuture<?> endBatch(); @Override void complete(); T submit(IndexManagementWork<T> work); T submit(IndexingWork<T> work); void forceCommit(); void forceRefresh(); } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceCommit() { try { indexAccessor.commit(); } catch (RuntimeException e) { indexAccessor.cleanUpAfterFailure( e, "Commit after a set of index works" ); throw e; } } LuceneBatchedWorkProcessor(EventContext eventContext,
IndexAccessor indexAccessor); @Override void beginBatch(); @Override CompletableFuture<?> endBatch(); @Override void complete(); T submit(IndexManagementWork<T> work); T submit(IndexingWork<T> work); void forceCommit(); void forceRefresh(); } |
@Test public void someNonFailingCloseables() { Throwable mainException = new Exception(); RuntimeException exception1 = new RuntimeException(); RuntimeException exception2 = new RuntimeException(); RuntimeException exception3 = new RuntimeException(); new SuppressingCloser( mainException ) .push( () -> { } ) .push( ignored -> { throw exception1; }, new Object() ) .push( ignored -> { throw exception2; }, new Object() ) .push( () -> { } ) .push( () -> { } ) .push( ignored -> { throw exception3; }, new Object() ) .push( () -> { } ); assertThat( mainException ) .hasSuppressedException( exception1 ) .hasSuppressedException( exception2 ) .hasSuppressedException( exception3 ); } | public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } SuppressingCloser(Throwable mainThrowable); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } SuppressingCloser(Throwable mainThrowable); SuppressingCloser push(AutoCloseable closeable); SuppressingCloser pushAll(AutoCloseable ... closeables); SuppressingCloser pushAll(Iterable<? extends AutoCloseable> closeables); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } SuppressingCloser(Throwable mainThrowable); SuppressingCloser push(AutoCloseable closeable); SuppressingCloser pushAll(AutoCloseable ... closeables); SuppressingCloser pushAll(Iterable<? extends AutoCloseable> closeables); } |
@Test public void forceRefresh() { processor.forceRefresh(); verify( indexAccessorMock ).refresh(); verifyNoOtherIndexInteractionsAndClear(); } | public void forceRefresh() { indexAccessor.refresh(); } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceRefresh() { indexAccessor.refresh(); } } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceRefresh() { indexAccessor.refresh(); } LuceneBatchedWorkProcessor(EventContext eventContext,
IndexAccessor indexAccessor); } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceRefresh() { indexAccessor.refresh(); } LuceneBatchedWorkProcessor(EventContext eventContext,
IndexAccessor indexAccessor); @Override void beginBatch(); @Override CompletableFuture<?> endBatch(); @Override void complete(); T submit(IndexManagementWork<T> work); T submit(IndexingWork<T> work); void forceCommit(); void forceRefresh(); } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceRefresh() { indexAccessor.refresh(); } LuceneBatchedWorkProcessor(EventContext eventContext,
IndexAccessor indexAccessor); @Override void beginBatch(); @Override CompletableFuture<?> endBatch(); @Override void complete(); T submit(IndexManagementWork<T> work); T submit(IndexingWork<T> work); void forceCommit(); void forceRefresh(); } |
@Test public void error_forceRefresh() { RuntimeException refreshException = new RuntimeException( "Some message" ); doThrow( refreshException ).when( indexAccessorMock ).refresh(); assertThatThrownBy( () -> processor.forceRefresh() ) .isSameAs( refreshException ); verifyNoOtherIndexInteractionsAndClear(); } | public void forceRefresh() { indexAccessor.refresh(); } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceRefresh() { indexAccessor.refresh(); } } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceRefresh() { indexAccessor.refresh(); } LuceneBatchedWorkProcessor(EventContext eventContext,
IndexAccessor indexAccessor); } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceRefresh() { indexAccessor.refresh(); } LuceneBatchedWorkProcessor(EventContext eventContext,
IndexAccessor indexAccessor); @Override void beginBatch(); @Override CompletableFuture<?> endBatch(); @Override void complete(); T submit(IndexManagementWork<T> work); T submit(IndexingWork<T> work); void forceCommit(); void forceRefresh(); } | LuceneBatchedWorkProcessor implements BatchedWorkProcessor { public void forceRefresh() { indexAccessor.refresh(); } LuceneBatchedWorkProcessor(EventContext eventContext,
IndexAccessor indexAccessor); @Override void beginBatch(); @Override CompletableFuture<?> endBatch(); @Override void complete(); T submit(IndexManagementWork<T> work); T submit(IndexingWork<T> work); void forceCommit(); void forceRefresh(); } |
@Test public void success() { ArgumentCaptor<CompletableFuture<Void>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Void>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Void>> work3FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; ElasticsearchIndexIndexingPlanExecution<StubEntityReference> execution = new ElasticsearchIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, workMocks( 3 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work2FutureCaptor.getValue().complete( null ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work1FutureCaptor.getValue().complete( null ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work3FutureCaptor.getValue().complete( null ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).isEmpty(); softly.assertThat( report.failingEntityReferences() ).isEmpty(); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } |
@Test public void failure_work() { RuntimeException work1Exception = new RuntimeException( "work1" ); ArgumentCaptor<CompletableFuture<Void>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Void>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Void>> work3FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; ElasticsearchIndexIndexingPlanExecution<StubEntityReference> execution = new ElasticsearchIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, workMocks( 3 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work2FutureCaptor.getValue().complete( null ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work1FutureCaptor.getValue().completeExceptionally( work1Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work3FutureCaptor.getValue().complete( null ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).containsSame( work1Exception ); softly.assertThat( report.failingEntityReferences() ) .containsExactlyInAnyOrder( entityReference( 0 ) ); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } |
@Test public void failure_multipleWorks() { RuntimeException work1Exception = new RuntimeException( "work1" ); RuntimeException work3Exception = new RuntimeException( "work3" ); ArgumentCaptor<CompletableFuture<Void>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Void>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Void>> work3FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Void>> work4FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; ElasticsearchIndexIndexingPlanExecution<StubEntityReference> execution = new ElasticsearchIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, workMocks( 4 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verify( orchestratorMock ).submit( work4FutureCaptor.capture(), eq( workMocks.get( 3 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work2FutureCaptor.getValue().complete( null ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work1FutureCaptor.getValue().completeExceptionally( work1Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work3FutureCaptor.getValue().completeExceptionally( work3Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work4FutureCaptor.getValue().complete( null ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).containsSame( work1Exception ); assertThat( work1Exception ).hasSuppressedException( work3Exception ); softly.assertThat( report.failingEntityReferences() ) .containsExactlyInAnyOrder( entityReference( 0 ), entityReference( 2 ) ); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } |
@Test @TestForIssue(jiraKey = "HSEARCH-3851") public void failure_multipleWorksAndCreateEntityReference() { RuntimeException work1Exception = new RuntimeException( "work1" ); RuntimeException work3Exception = new RuntimeException( "work3" ); ArgumentCaptor<CompletableFuture<Void>> work1FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Void>> work2FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Void>> work3FutureCaptor = futureCaptor(); ArgumentCaptor<CompletableFuture<Void>> work4FutureCaptor = futureCaptor(); CompletableFuture<IndexIndexingPlanExecutionReport<StubEntityReference>> planExecutionFuture; ElasticsearchIndexIndexingPlanExecution<StubEntityReference> execution = new ElasticsearchIndexIndexingPlanExecution<>( orchestratorMock, entityReferenceFactoryMock, workMocks( 4 ) ); verifyNoOtherOrchestratorInteractionsAndReset(); planExecutionFuture = execution.execute(); verify( orchestratorMock ).submit( work1FutureCaptor.capture(), eq( workMocks.get( 0 ) ) ); verify( orchestratorMock ).submit( work2FutureCaptor.capture(), eq( workMocks.get( 1 ) ) ); verify( orchestratorMock ).submit( work3FutureCaptor.capture(), eq( workMocks.get( 2 ) ) ); verify( orchestratorMock ).submit( work4FutureCaptor.capture(), eq( workMocks.get( 3 ) ) ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work2FutureCaptor.getValue().complete( null ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work1FutureCaptor.getValue().completeExceptionally( work1Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); work3FutureCaptor.getValue().completeExceptionally( work3Exception ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isPending(); RuntimeException entityReferenceFactoryException = new RuntimeException( "EntityReferenceFactory message" ); when( entityReferenceFactoryMock.createEntityReference( TYPE_NAME, 0 ) ) .thenThrow( entityReferenceFactoryException ); work4FutureCaptor.getValue().complete( null ); verifyNoOtherOrchestratorInteractionsAndReset(); assertThatFuture( planExecutionFuture ).isSuccessful( report -> { assertThat( report ).isNotNull(); assertSoftly( softly -> { softly.assertThat( report.throwable() ).containsSame( work1Exception ); softly.assertThat( work1Exception ).hasSuppressedException( entityReferenceFactoryException ); softly.assertThat( report.failingEntityReferences() ) .containsExactly( entityReference( 2 ) ); } ); } ); } | CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } | ElasticsearchIndexIndexingPlanExecution { CompletableFuture<IndexIndexingPlanExecutionReport<R>> execute() { CompletableFuture<IndexIndexingPlanExecutionReport<R>> reportFuture = CompletableFuture.allOf( futures ) .handle( (result, throwable) -> onAllWorksFinished() ); for ( int i = 0; i < works.size(); i++ ) { CompletableFuture<Void> future = futures[i]; SingleDocumentIndexingWork work = works.get( i ); orchestrator.submit( future, work ); } return reportFuture; } ElasticsearchIndexIndexingPlanExecution(ElasticsearchSerialWorkOrchestrator orchestrator,
EntityReferenceFactory<R> entityReferenceFactory,
List<SingleDocumentIndexingWork> works); } |
@Test public void initialContentLength() { assumeTrue( expectedContentLength < 1024 ); assertThat( gsonEntity.getContentLength() ).isEqualTo( expectedContentLength ); } | @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } |
@Test public void contentType() { Header contentType = gsonEntity.getContentType(); assertThat( contentType.getName() ).isEqualTo( "Content-Type" ); assertThat( contentType.getValue() ).isEqualTo( "application/json; charset=UTF-8" ); } | @Override public Header getContentType() { return CONTENT_TYPE; } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public Header getContentType() { return CONTENT_TYPE; } } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public Header getContentType() { return CONTENT_TYPE; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public Header getContentType() { return CONTENT_TYPE; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public Header getContentType() { return CONTENT_TYPE; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } |
@Test public void produceContent_noPushBack() throws IOException { int pushBackPeriod = Integer.MAX_VALUE; for ( int i = 0; i < 2; i++ ) { assertThat( doProduceContent( gsonEntity, pushBackPeriod ) ) .isEqualTo( expectedPayloadString ); assertThat( gsonEntity.getContentLength() ) .isEqualTo( expectedContentLength ); } } | @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } |
@Test public void produceContent_pushBack_every5Bytes() throws IOException { int pushBackPeriod = 5; for ( int i = 0; i < 2; i++ ) { assertThat( doProduceContent( gsonEntity, pushBackPeriod ) ) .isEqualTo( expectedPayloadString ); assertThat( gsonEntity.getContentLength() ) .isEqualTo( expectedContentLength ); } } | @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } |
@Test public void onlyNonFailingCloseables() { Throwable mainException = new Exception(); new SuppressingCloser( mainException ) .push( () -> { } ) .push( () -> { } ); assertThat( mainException ) .hasNoSuppressedExceptions(); } | public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } SuppressingCloser(Throwable mainThrowable); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } SuppressingCloser(Throwable mainThrowable); SuppressingCloser push(AutoCloseable closeable); SuppressingCloser pushAll(AutoCloseable ... closeables); SuppressingCloser pushAll(Iterable<? extends AutoCloseable> closeables); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } SuppressingCloser(Throwable mainThrowable); SuppressingCloser push(AutoCloseable closeable); SuppressingCloser pushAll(AutoCloseable ... closeables); SuppressingCloser pushAll(Iterable<? extends AutoCloseable> closeables); } |
@Test public void produceContent_pushBack_every100Bytes() throws IOException { int pushBackPeriod = 100; for ( int i = 0; i < 2; i++ ) { assertThat( doProduceContent( gsonEntity, pushBackPeriod ) ) .isEqualTo( expectedPayloadString ); assertThat( gsonEntity.getContentLength() ) .isEqualTo( expectedContentLength ); } } | @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } |
@Test public void produceContent_pushBack_every500Bytes() throws IOException { int pushBackPeriod = 500; for ( int i = 0; i < 2; i++ ) { assertThat( doProduceContent( gsonEntity, pushBackPeriod ) ) .isEqualTo( expectedPayloadString ); assertThat( gsonEntity.getContentLength() ) .isEqualTo( expectedContentLength ); } } | @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public long getContentLength() { this.contentLengthWasProvided = true; return this.contentLength; } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } |
@Test public void writeTo() throws IOException { for ( int i = 0; i < 2; i++ ) { assertThat( doWriteTo( gsonEntity ) ) .isEqualTo( expectedPayloadString ); assertThat( gsonEntity.getContentLength() ) .isEqualTo( expectedContentLength ); } } | @Override public void writeTo(OutputStream out) throws IOException { CountingOutputStream countingStream = new CountingOutputStream( out ); Writer writer = new OutputStreamWriter( countingStream, CHARSET ); for ( JsonObject bodyPart : bodyParts ) { gson.toJson( bodyPart, writer ); writer.append( '\n' ); } writer.flush(); hintContentLength( countingStream.getBytesWritten() ); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public void writeTo(OutputStream out) throws IOException { CountingOutputStream countingStream = new CountingOutputStream( out ); Writer writer = new OutputStreamWriter( countingStream, CHARSET ); for ( JsonObject bodyPart : bodyParts ) { gson.toJson( bodyPart, writer ); writer.append( '\n' ); } writer.flush(); hintContentLength( countingStream.getBytesWritten() ); } } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public void writeTo(OutputStream out) throws IOException { CountingOutputStream countingStream = new CountingOutputStream( out ); Writer writer = new OutputStreamWriter( countingStream, CHARSET ); for ( JsonObject bodyPart : bodyParts ) { gson.toJson( bodyPart, writer ); writer.append( '\n' ); } writer.flush(); hintContentLength( countingStream.getBytesWritten() ); } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public void writeTo(OutputStream out) throws IOException { CountingOutputStream countingStream = new CountingOutputStream( out ); Writer writer = new OutputStreamWriter( countingStream, CHARSET ); for ( JsonObject bodyPart : bodyParts ) { gson.toJson( bodyPart, writer ); writer.append( '\n' ); } writer.flush(); hintContentLength( countingStream.getBytesWritten() ); } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public void writeTo(OutputStream out) throws IOException { CountingOutputStream countingStream = new CountingOutputStream( out ); Writer writer = new OutputStreamWriter( countingStream, CHARSET ); for ( JsonObject bodyPart : bodyParts ) { gson.toJson( bodyPart, writer ); writer.append( '\n' ); } writer.flush(); hintContentLength( countingStream.getBytesWritten() ); } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } |
@Test public void getContent() throws IOException { for ( int i = 0; i < 2; i++ ) { assertThat( doGetContent( gsonEntity ) ) .isEqualTo( expectedPayloadString ); assertThat( gsonEntity.getContentLength() ) .isEqualTo( expectedContentLength ); } } | @Override public InputStream getContent() { return new HttpAsyncContentProducerInputStream( this, BYTE_BUFFER_PAGE_SIZE ); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public InputStream getContent() { return new HttpAsyncContentProducerInputStream( this, BYTE_BUFFER_PAGE_SIZE ); } } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public InputStream getContent() { return new HttpAsyncContentProducerInputStream( this, BYTE_BUFFER_PAGE_SIZE ); } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public InputStream getContent() { return new HttpAsyncContentProducerInputStream( this, BYTE_BUFFER_PAGE_SIZE ); } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } | GsonHttpEntity implements HttpEntity, HttpAsyncContentProducer { @Override public InputStream getContent() { return new HttpAsyncContentProducerInputStream( this, BYTE_BUFFER_PAGE_SIZE ); } GsonHttpEntity(Gson gson, List<JsonObject> bodyParts); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override Header getContentType(); @Override Header getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(OutputStream out); @Override boolean isStreaming(); @Override @SuppressWarnings("deprecation") // javac warns about this method being deprecated, but we have to implement it void consumeContent(); @Override void close(); @Override void produceContent(ContentEncoder encoder, IOControl ioctrl); } |
@Test public void customCloseable() { Throwable mainException = new Exception(); MyException1 exception1 = new MyException1(); RuntimeException exception2 = new IllegalStateException(); @SuppressWarnings("resource") MyException1Closeable closeable = () -> { throw exception1; }; new SuppressingCloser( mainException ) .push( closeable ) .push( ignored -> { throw exception2; }, new Object() ); assertThat( mainException ) .hasSuppressedException( exception1 ); } | public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } SuppressingCloser(Throwable mainThrowable); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } SuppressingCloser(Throwable mainThrowable); SuppressingCloser push(AutoCloseable closeable); SuppressingCloser pushAll(AutoCloseable ... closeables); SuppressingCloser pushAll(Iterable<? extends AutoCloseable> closeables); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser push(AutoCloseable closeable) { return push( AutoCloseable::close, closeable ); } SuppressingCloser(Throwable mainThrowable); SuppressingCloser push(AutoCloseable closeable); SuppressingCloser pushAll(AutoCloseable ... closeables); SuppressingCloser pushAll(Iterable<? extends AutoCloseable> closeables); } |
@Test public void iterable() throws IOException { Throwable mainException = new Exception(); IOException exception1 = new IOException(); RuntimeException exception2 = new IllegalStateException(); IOException exception3 = new IOException(); RuntimeException exception4 = new UnsupportedOperationException(); List<Closeable> closeables = Arrays.asList( () -> { throw exception1; }, () -> { throw exception2; }, () -> { throw exception3; }, () -> { throw exception4; } ); new SuppressingCloser( mainException ) .pushAll( closeables ); assertThat( mainException ) .hasSuppressedException( exception1 ) .hasSuppressedException( exception2 ) .hasSuppressedException( exception3 ) .hasSuppressedException( exception4 ); } | public SuppressingCloser pushAll(AutoCloseable ... closeables) { return pushAll( AutoCloseable::close, closeables ); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser pushAll(AutoCloseable ... closeables) { return pushAll( AutoCloseable::close, closeables ); } } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser pushAll(AutoCloseable ... closeables) { return pushAll( AutoCloseable::close, closeables ); } SuppressingCloser(Throwable mainThrowable); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser pushAll(AutoCloseable ... closeables) { return pushAll( AutoCloseable::close, closeables ); } SuppressingCloser(Throwable mainThrowable); SuppressingCloser push(AutoCloseable closeable); SuppressingCloser pushAll(AutoCloseable ... closeables); SuppressingCloser pushAll(Iterable<? extends AutoCloseable> closeables); } | SuppressingCloser extends AbstractCloser<SuppressingCloser, Exception> { public SuppressingCloser pushAll(AutoCloseable ... closeables) { return pushAll( AutoCloseable::close, closeables ); } SuppressingCloser(Throwable mainThrowable); SuppressingCloser push(AutoCloseable closeable); SuppressingCloser pushAll(AutoCloseable ... closeables); SuppressingCloser pushAll(Iterable<? extends AutoCloseable> closeables); } |
@Test public void deserializeInt_fromInt() throws Exception { int i = SerializationUtil.parseIntegerParameter( "My parameter", "1" ); assertThat( i ).isEqualTo( 1 ); } | public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } |
@Test public void deserializeInt_fromDouble() throws Exception { thrown.expect( SearchException.class ); thrown.expectMessage( "HSEARCH500029: Unable to parse value '1.0' for job parameter 'My parameter'." ); SerializationUtil.parseIntegerParameter( "My parameter", "1.0" ); } | public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } |
@Test public void deserializeInt_fromOther() throws Exception { thrown.expect( SearchException.class ); thrown.expectMessage( "HSEARCH500029: Unable to parse value 'foo' for job parameter 'My parameter'." ); SerializationUtil.parseIntegerParameter( "My parameter", "foo" ); } | public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } |
@Test public void deserializeInt_missing() throws Exception { thrown.expect( SearchException.class ); thrown.expectMessage( "HSEARCH500029: Unable to parse value 'null' for job parameter 'My parameter'." ); SerializationUtil.parseIntegerParameter( "My parameter", null ); } | public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } | SerializationUtil { public static int parseIntegerParameter(String key, String value) { try { return Integer.parseInt( value ); } catch (NumberFormatException e) { throw log.unableToParseJobParameter( key, value, e ); } } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } |
@Test public void deserializeInt_defaultValue() throws Exception { int i = SerializationUtil.parseIntegerParameterOptional( "My parameter", null, 1 ); assertThat( i ).isEqualTo( 1 ); } | public static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue) { if ( value == null ) { return defaultValue; } else { return parseIntegerParameter( key, value ); } } | SerializationUtil { public static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue) { if ( value == null ) { return defaultValue; } else { return parseIntegerParameter( key, value ); } } } | SerializationUtil { public static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue) { if ( value == null ) { return defaultValue; } else { return parseIntegerParameter( key, value ); } } private SerializationUtil(); } | SerializationUtil { public static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue) { if ( value == null ) { return defaultValue; } else { return parseIntegerParameter( key, value ); } } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } | SerializationUtil { public static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue) { if ( value == null ) { return defaultValue; } else { return parseIntegerParameter( key, value ); } } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } |
@Test public void deserializeBoolean_fromLowerCase() throws Exception { boolean t = SerializationUtil.parseBooleanParameterOptional( "My parameter 1", "true", false ); boolean f = SerializationUtil.parseBooleanParameterOptional( "My parameter 2", "false", true ); assertThat( t ).isTrue(); assertThat( f ).isFalse(); } | public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } |
@Test public void matches() { assertSoftly( softly -> { for ( String candidate : expectedMatching ) { softly.assertThat( pattern.matches( candidate ) ) .as( "'" + patternString + "' matches '" + candidate + "'" ) .isTrue(); } for ( String candidate : expectedNonMatching ) { softly.assertThat( pattern.matches( candidate ) ) .as( "'" + patternString + "' matches '" + candidate + "'" ) .isFalse(); } } ); } | public boolean matches(String candidate) { return matches( candidate, 0 ); } | SimpleGlobPattern { public boolean matches(String candidate) { return matches( candidate, 0 ); } } | SimpleGlobPattern { public boolean matches(String candidate) { return matches( candidate, 0 ); } private SimpleGlobPattern(); } | SimpleGlobPattern { public boolean matches(String candidate) { return matches( candidate, 0 ); } private SimpleGlobPattern(); static SimpleGlobPattern compile(String patternString); boolean matches(String candidate); SimpleGlobPattern prependLiteral(String literal); SimpleGlobPattern prependMany(); Optional<String> toLiteral(); abstract String toPatternString(); } | SimpleGlobPattern { public boolean matches(String candidate) { return matches( candidate, 0 ); } private SimpleGlobPattern(); static SimpleGlobPattern compile(String patternString); boolean matches(String candidate); SimpleGlobPattern prependLiteral(String literal); SimpleGlobPattern prependMany(); Optional<String> toLiteral(); abstract String toPatternString(); } |
@Test public void deserializeBoolean_fromUpperCase() throws Exception { boolean t = SerializationUtil.parseBooleanParameterOptional( "My parameter 1", "TRUE", false ); boolean f = SerializationUtil.parseBooleanParameterOptional( "My parameter 2", "FALSE", true ); assertThat( t ).isTrue(); assertThat( f ).isFalse(); } | public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } |
@Test public void deserializeBoolean_fromIrregularCase() throws Exception { boolean t = SerializationUtil.parseBooleanParameterOptional( "My parameter 1", "TruE", false ); boolean f = SerializationUtil.parseBooleanParameterOptional( "My parameter 2", "FalSe", true ); assertThat( t ).as( "Case should be ignored." ).isTrue(); assertThat( f ).as( "Case should be ignored." ).isFalse(); } | public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } |
@Test public void deserializeBoolean_fromMissing() throws Exception { boolean t = SerializationUtil.parseBooleanParameterOptional( "My parameter 1", null, true ); boolean f = SerializationUtil.parseBooleanParameterOptional( "My parameter 2", null, false ); assertThat( t ).as( "Default value should be returned." ).isTrue(); assertThat( f ).as( "Default value should be returned." ).isFalse(); } | public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } |
@Test public void deserializeBoolean_fromOthers() throws Exception { for ( String value : new String[] { "", "0", "1", "t", "f" } ) { try { SerializationUtil.parseBooleanParameterOptional( "My parameter", value, true ); fail(); } catch (SearchException e) { String expectedMsg = "HSEARCH500029: Unable to parse value '" + value + "' for job parameter 'My parameter'."; assertThat( e.getMessage() ).isEqualTo( expectedMsg ); } } } | public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } | SerializationUtil { public static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue) { if ( value == null ) { return defaultValue; } if ( "true".equalsIgnoreCase( value ) ) { return true; } if ( "false".equalsIgnoreCase( value ) ) { return false; } throw log.unableToParseJobParameter( key, value, null ); } private SerializationUtil(); static String serialize(Object object); static Object deserialize(String serialized); static boolean parseBooleanParameterOptional(String key, String value, boolean defaultValue); static int parseIntegerParameter(String key, String value); static Integer parseIntegerParameterOptional(String key, String value, Integer defaultValue); @SuppressWarnings("unchecked") static T parseParameter(@SuppressWarnings("unused") Class<T> type, String key, String value); static CacheMode parseCacheModeParameter(String key, String value, CacheMode defaultValue); } |
@Test public void validateEntityTypes_whenAllTypesAreAvailableInEMF() throws Exception { String serializedEntityTypes = Stream .of( Company.class, Person.class ) .map( Class::getName ) .collect( Collectors.joining( "," ) ); ValidationUtil.validateEntityTypes( null, EMF_SCOPE, PERSISTENCE_UNIT_NAME, serializedEntityTypes ); } | public static void validateEntityTypes( EntityManagerFactoryRegistry emfRegistry, String entityManagerFactoryScope, String entityManagerFactoryReference, String serializedEntityTypes) { EntityManagerFactory emf = JobContextUtil.getEntityManagerFactory( emfRegistry, entityManagerFactoryScope, entityManagerFactoryReference ); ExtendedSearchIntegrator searchIntegrator = ContextHelper.getSearchIntegratorBySF( emf.unwrap( SessionFactory.class ) ); Set<String> failingTypes = new HashSet<>(); IndexedTypeSet typeIds = searchIntegrator .getIndexedTypeIdentifiers(); Set<String> indexedTypes = new HashSet<>(); for ( IndexedTypeIdentifier typeId : typeIds ) { indexedTypes.add( typeId.getName() ); } for ( String type : serializedEntityTypes.split( "," ) ) { if ( !indexedTypes.contains( type ) ) { failingTypes.add( type ); } } if ( failingTypes.size() > 0 ) { throw log.failingEntityTypes( String.join( ", ", failingTypes ) ); } } | ValidationUtil { public static void validateEntityTypes( EntityManagerFactoryRegistry emfRegistry, String entityManagerFactoryScope, String entityManagerFactoryReference, String serializedEntityTypes) { EntityManagerFactory emf = JobContextUtil.getEntityManagerFactory( emfRegistry, entityManagerFactoryScope, entityManagerFactoryReference ); ExtendedSearchIntegrator searchIntegrator = ContextHelper.getSearchIntegratorBySF( emf.unwrap( SessionFactory.class ) ); Set<String> failingTypes = new HashSet<>(); IndexedTypeSet typeIds = searchIntegrator .getIndexedTypeIdentifiers(); Set<String> indexedTypes = new HashSet<>(); for ( IndexedTypeIdentifier typeId : typeIds ) { indexedTypes.add( typeId.getName() ); } for ( String type : serializedEntityTypes.split( "," ) ) { if ( !indexedTypes.contains( type ) ) { failingTypes.add( type ); } } if ( failingTypes.size() > 0 ) { throw log.failingEntityTypes( String.join( ", ", failingTypes ) ); } } } | ValidationUtil { public static void validateEntityTypes( EntityManagerFactoryRegistry emfRegistry, String entityManagerFactoryScope, String entityManagerFactoryReference, String serializedEntityTypes) { EntityManagerFactory emf = JobContextUtil.getEntityManagerFactory( emfRegistry, entityManagerFactoryScope, entityManagerFactoryReference ); ExtendedSearchIntegrator searchIntegrator = ContextHelper.getSearchIntegratorBySF( emf.unwrap( SessionFactory.class ) ); Set<String> failingTypes = new HashSet<>(); IndexedTypeSet typeIds = searchIntegrator .getIndexedTypeIdentifiers(); Set<String> indexedTypes = new HashSet<>(); for ( IndexedTypeIdentifier typeId : typeIds ) { indexedTypes.add( typeId.getName() ); } for ( String type : serializedEntityTypes.split( "," ) ) { if ( !indexedTypes.contains( type ) ) { failingTypes.add( type ); } } if ( failingTypes.size() > 0 ) { throw log.failingEntityTypes( String.join( ", ", failingTypes ) ); } } private ValidationUtil(); } | ValidationUtil { public static void validateEntityTypes( EntityManagerFactoryRegistry emfRegistry, String entityManagerFactoryScope, String entityManagerFactoryReference, String serializedEntityTypes) { EntityManagerFactory emf = JobContextUtil.getEntityManagerFactory( emfRegistry, entityManagerFactoryScope, entityManagerFactoryReference ); ExtendedSearchIntegrator searchIntegrator = ContextHelper.getSearchIntegratorBySF( emf.unwrap( SessionFactory.class ) ); Set<String> failingTypes = new HashSet<>(); IndexedTypeSet typeIds = searchIntegrator .getIndexedTypeIdentifiers(); Set<String> indexedTypes = new HashSet<>(); for ( IndexedTypeIdentifier typeId : typeIds ) { indexedTypes.add( typeId.getName() ); } for ( String type : serializedEntityTypes.split( "," ) ) { if ( !indexedTypes.contains( type ) ) { failingTypes.add( type ); } } if ( failingTypes.size() > 0 ) { throw log.failingEntityTypes( String.join( ", ", failingTypes ) ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validateEntityTypes( EntityManagerFactoryRegistry emfRegistry, String entityManagerFactoryScope, String entityManagerFactoryReference, String serializedEntityTypes) { EntityManagerFactory emf = JobContextUtil.getEntityManagerFactory( emfRegistry, entityManagerFactoryScope, entityManagerFactoryReference ); ExtendedSearchIntegrator searchIntegrator = ContextHelper.getSearchIntegratorBySF( emf.unwrap( SessionFactory.class ) ); Set<String> failingTypes = new HashSet<>(); IndexedTypeSet typeIds = searchIntegrator .getIndexedTypeIdentifiers(); Set<String> indexedTypes = new HashSet<>(); for ( IndexedTypeIdentifier typeId : typeIds ) { indexedTypes.add( typeId.getName() ); } for ( String type : serializedEntityTypes.split( "," ) ) { if ( !indexedTypes.contains( type ) ) { failingTypes.add( type ); } } if ( failingTypes.size() > 0 ) { throw log.failingEntityTypes( String.join( ", ", failingTypes ) ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test public void validateEntityTypes_whenContainingNonIndexedTypes() throws Exception { String serializedEntityTypes = Stream .of( Company.class, Person.class, NotIndexed.class ) .map( Class::getName ) .collect( Collectors.joining( "," ) ); thrown.expect( SearchException.class ); thrown.expectMessage( "HSEARCH500032: The following selected entity types aren't indexable: " + NotIndexed.class .getName() + ". Please check if the annotation '@Indexed' has been added to each of them." ); ValidationUtil.validateEntityTypes( null, EMF_SCOPE, PERSISTENCE_UNIT_NAME, serializedEntityTypes ); } | public static void validateEntityTypes( EntityManagerFactoryRegistry emfRegistry, String entityManagerFactoryScope, String entityManagerFactoryReference, String serializedEntityTypes) { EntityManagerFactory emf = JobContextUtil.getEntityManagerFactory( emfRegistry, entityManagerFactoryScope, entityManagerFactoryReference ); ExtendedSearchIntegrator searchIntegrator = ContextHelper.getSearchIntegratorBySF( emf.unwrap( SessionFactory.class ) ); Set<String> failingTypes = new HashSet<>(); IndexedTypeSet typeIds = searchIntegrator .getIndexedTypeIdentifiers(); Set<String> indexedTypes = new HashSet<>(); for ( IndexedTypeIdentifier typeId : typeIds ) { indexedTypes.add( typeId.getName() ); } for ( String type : serializedEntityTypes.split( "," ) ) { if ( !indexedTypes.contains( type ) ) { failingTypes.add( type ); } } if ( failingTypes.size() > 0 ) { throw log.failingEntityTypes( String.join( ", ", failingTypes ) ); } } | ValidationUtil { public static void validateEntityTypes( EntityManagerFactoryRegistry emfRegistry, String entityManagerFactoryScope, String entityManagerFactoryReference, String serializedEntityTypes) { EntityManagerFactory emf = JobContextUtil.getEntityManagerFactory( emfRegistry, entityManagerFactoryScope, entityManagerFactoryReference ); ExtendedSearchIntegrator searchIntegrator = ContextHelper.getSearchIntegratorBySF( emf.unwrap( SessionFactory.class ) ); Set<String> failingTypes = new HashSet<>(); IndexedTypeSet typeIds = searchIntegrator .getIndexedTypeIdentifiers(); Set<String> indexedTypes = new HashSet<>(); for ( IndexedTypeIdentifier typeId : typeIds ) { indexedTypes.add( typeId.getName() ); } for ( String type : serializedEntityTypes.split( "," ) ) { if ( !indexedTypes.contains( type ) ) { failingTypes.add( type ); } } if ( failingTypes.size() > 0 ) { throw log.failingEntityTypes( String.join( ", ", failingTypes ) ); } } } | ValidationUtil { public static void validateEntityTypes( EntityManagerFactoryRegistry emfRegistry, String entityManagerFactoryScope, String entityManagerFactoryReference, String serializedEntityTypes) { EntityManagerFactory emf = JobContextUtil.getEntityManagerFactory( emfRegistry, entityManagerFactoryScope, entityManagerFactoryReference ); ExtendedSearchIntegrator searchIntegrator = ContextHelper.getSearchIntegratorBySF( emf.unwrap( SessionFactory.class ) ); Set<String> failingTypes = new HashSet<>(); IndexedTypeSet typeIds = searchIntegrator .getIndexedTypeIdentifiers(); Set<String> indexedTypes = new HashSet<>(); for ( IndexedTypeIdentifier typeId : typeIds ) { indexedTypes.add( typeId.getName() ); } for ( String type : serializedEntityTypes.split( "," ) ) { if ( !indexedTypes.contains( type ) ) { failingTypes.add( type ); } } if ( failingTypes.size() > 0 ) { throw log.failingEntityTypes( String.join( ", ", failingTypes ) ); } } private ValidationUtil(); } | ValidationUtil { public static void validateEntityTypes( EntityManagerFactoryRegistry emfRegistry, String entityManagerFactoryScope, String entityManagerFactoryReference, String serializedEntityTypes) { EntityManagerFactory emf = JobContextUtil.getEntityManagerFactory( emfRegistry, entityManagerFactoryScope, entityManagerFactoryReference ); ExtendedSearchIntegrator searchIntegrator = ContextHelper.getSearchIntegratorBySF( emf.unwrap( SessionFactory.class ) ); Set<String> failingTypes = new HashSet<>(); IndexedTypeSet typeIds = searchIntegrator .getIndexedTypeIdentifiers(); Set<String> indexedTypes = new HashSet<>(); for ( IndexedTypeIdentifier typeId : typeIds ) { indexedTypes.add( typeId.getName() ); } for ( String type : serializedEntityTypes.split( "," ) ) { if ( !indexedTypes.contains( type ) ) { failingTypes.add( type ); } } if ( failingTypes.size() > 0 ) { throw log.failingEntityTypes( String.join( ", ", failingTypes ) ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validateEntityTypes( EntityManagerFactoryRegistry emfRegistry, String entityManagerFactoryScope, String entityManagerFactoryReference, String serializedEntityTypes) { EntityManagerFactory emf = JobContextUtil.getEntityManagerFactory( emfRegistry, entityManagerFactoryScope, entityManagerFactoryReference ); ExtendedSearchIntegrator searchIntegrator = ContextHelper.getSearchIntegratorBySF( emf.unwrap( SessionFactory.class ) ); Set<String> failingTypes = new HashSet<>(); IndexedTypeSet typeIds = searchIntegrator .getIndexedTypeIdentifiers(); Set<String> indexedTypes = new HashSet<>(); for ( IndexedTypeIdentifier typeId : typeIds ) { indexedTypes.add( typeId.getName() ); } for ( String type : serializedEntityTypes.split( "," ) ) { if ( !indexedTypes.contains( type ) ) { failingTypes.add( type ); } } if ( failingTypes.size() > 0 ) { throw log.failingEntityTypes( String.join( ", ", failingTypes ) ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test(expected = SearchException.class) public void validatePositive_valueIsNegative() throws Exception { ValidationUtil.validatePositive( "MyParameter", -1 ); } | public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } private ValidationUtil(); } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test(expected = SearchException.class) public void validatePositive_valueIsZero() throws Exception { ValidationUtil.validatePositive( "MyParameter", 0 ); } | public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } private ValidationUtil(); } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test public void validatePositive_valueIsPositive() throws Exception { ValidationUtil.validatePositive( "MyParameter", 1 ); } | public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } private ValidationUtil(); } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validatePositive(String parameterName, int parameterValue) { if ( parameterValue <= 0 ) { throw log.negativeValueOrZero( parameterName, parameterValue ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test public void validateCheckpointInterval_lessThanRowsPerPartition() throws Exception { ValidationUtil.validateCheckpointInterval( 99, 100 ); } | public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } private ValidationUtil(); } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test public void toPatternString() { assertThat( pattern.toPatternString() ).isEqualTo( expectedToPatternString ); } | public abstract String toPatternString(); | SimpleGlobPattern { public abstract String toPatternString(); } | SimpleGlobPattern { public abstract String toPatternString(); private SimpleGlobPattern(); } | SimpleGlobPattern { public abstract String toPatternString(); private SimpleGlobPattern(); static SimpleGlobPattern compile(String patternString); boolean matches(String candidate); SimpleGlobPattern prependLiteral(String literal); SimpleGlobPattern prependMany(); Optional<String> toLiteral(); abstract String toPatternString(); } | SimpleGlobPattern { public abstract String toPatternString(); private SimpleGlobPattern(); static SimpleGlobPattern compile(String patternString); boolean matches(String candidate); SimpleGlobPattern prependLiteral(String literal); SimpleGlobPattern prependMany(); Optional<String> toLiteral(); abstract String toPatternString(); } |
@Test public void validateCheckpointInterval_equalToRowsPerPartition() { ValidationUtil.validateCheckpointInterval( 100, 100 ); } | public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } private ValidationUtil(); } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test(expected = SearchException.class) public void validateCheckpointInterval_greaterThanRowsPerPartition() throws Exception { ValidationUtil.validateCheckpointInterval( 101, 100 ); } | public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } private ValidationUtil(); } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition) { if ( checkpointInterval > rowsPerPartition ) { throw log.illegalCheckpointInterval( checkpointInterval, rowsPerPartition ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test public void validateSessionClearInterval_lessThanCheckpointInterval() throws Exception { ValidationUtil.validateSessionClearInterval( 99, 100 ); } | public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } private ValidationUtil(); } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test public void validateSessionClearInterval_equalToCheckpointInterval() { ValidationUtil.validateSessionClearInterval( 100, 100 ); } | public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } private ValidationUtil(); } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test(expected = SearchException.class) public void validateSessionClearInterval_greaterThanCheckpointInterval() throws Exception { ValidationUtil.validateSessionClearInterval( 101, 100 ); } | public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } private ValidationUtil(); } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } | ValidationUtil { public static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval) { if ( sessionClearInterval > checkpointInterval ) { throw log.illegalSessionClearInterval( sessionClearInterval, checkpointInterval ); } } private ValidationUtil(); static void validateCheckpointInterval(int checkpointInterval, int rowsPerPartition); static void validateSessionClearInterval(int sessionClearInterval, int checkpointInterval); static void validatePositive(String parameterName, int parameterValue); static void validateEntityTypes(
EntityManagerFactoryRegistry emfRegistry,
String entityManagerFactoryScope,
String entityManagerFactoryReference,
String serializedEntityTypes); } |
@Test public void testMapPartitions() throws Exception { JobContextData jobData = new JobContextData(); jobData.setEntityManagerFactory( emf ); jobData.setCustomQueryCriteria( new HashSet<>() ); jobData.setEntityTypeDescriptors( Arrays.asList( JobTestUtil.createSimpleEntityTypeDescriptor( emf, Company.class ), JobTestUtil.createSimpleEntityTypeDescriptor( emf, Person.class ) ) ); when( mockedJobContext.getTransientUserData() ).thenReturn( jobData ); PartitionPlan partitionPlan = partitionMapper.mapPartitions(); int compPartitions = 0; int persPartitions = 0; for ( Properties p : partitionPlan.getPartitionProperties() ) { String entityName = p.getProperty( MassIndexingPartitionProperties.ENTITY_NAME ); if ( entityName.equals( Company.class.getName() ) ) { compPartitions++; } if ( entityName.equals( Person.class.getName() ) ) { persPartitions++; } String checkpointInterval = p.getProperty( MassIndexingPartitionProperties.CHECKPOINT_INTERVAL ); assertNotNull( checkpointInterval ); assertEquals( "3", checkpointInterval ); } assertEquals( 1, compPartitions ); assertEquals( 3, persPartitions ); } | @Override public PartitionPlan mapPartitions() throws Exception { JobContextData jobData = (JobContextData) jobContext.getTransientUserData(); emf = jobData.getEntityManagerFactory(); try ( StatelessSession ss = PersistenceUtil.openStatelessSession( emf, tenantId ) ) { Integer maxResults = SerializationUtil.parseIntegerParameterOptional( MAX_RESULTS_PER_ENTITY, serializedMaxResultsPerEntity, null ); int rowsPerPartition = SerializationUtil.parseIntegerParameterOptional( ROWS_PER_PARTITION, serializedRowsPerPartition, Defaults.ROWS_PER_PARTITION ); Integer checkpointIntervalRaw = SerializationUtil.parseIntegerParameterOptional( CHECKPOINT_INTERVAL, serializedCheckpointInterval, null ); int checkpointInterval = Defaults.checkpointInterval( checkpointIntervalRaw, rowsPerPartition ); int idFetchSize = SerializationUtil.parseIntegerParameterOptional( ID_FETCH_SIZE, serializedIdFetchSize, Defaults.ID_FETCH_SIZE ); List<EntityTypeDescriptor> entityTypeDescriptors = jobData.getEntityTypeDescriptors(); List<PartitionBound> partitionBounds = new ArrayList<>(); switch ( PersistenceUtil.getIndexScope( customQueryHql, jobData.getCustomQueryCriteria() ) ) { case HQL: Class<?> clazz = entityTypeDescriptors.get( 0 ).getJavaClass(); partitionBounds.add( new PartitionBound( clazz, null, null, IndexScope.HQL ) ); break; case CRITERIA: partitionBounds = buildPartitionUnitsFrom( ss, entityTypeDescriptors.get( 0 ), jobData.getCustomQueryCriteria(), maxResults, idFetchSize, rowsPerPartition, IndexScope.CRITERIA ); break; case FULL_ENTITY: for ( EntityTypeDescriptor entityTypeDescriptor : entityTypeDescriptors ) { partitionBounds.addAll( buildPartitionUnitsFrom( ss, entityTypeDescriptor, Collections.emptySet(), maxResults, idFetchSize, rowsPerPartition, IndexScope.FULL_ENTITY ) ); } break; } final int partitions = partitionBounds.size(); final Properties[] props = new Properties[partitions]; for ( int i = 0; i < partitionBounds.size(); i++ ) { PartitionBound bound = partitionBounds.get( i ); props[i] = new Properties(); props[i].setProperty( MassIndexingPartitionProperties.ENTITY_NAME, bound.getEntityName() ); props[i].setProperty( MassIndexingPartitionProperties.PARTITION_ID, String.valueOf( i ) ); props[i].setProperty( MassIndexingPartitionProperties.LOWER_BOUND, SerializationUtil.serialize( bound.getLowerBound() ) ); props[i].setProperty( MassIndexingPartitionProperties.UPPER_BOUND, SerializationUtil.serialize( bound.getUpperBound() ) ); props[i].setProperty( MassIndexingPartitionProperties.INDEX_SCOPE, bound.getIndexScope().name() ); props[i].setProperty( MassIndexingPartitionProperties.CHECKPOINT_INTERVAL, String.valueOf( checkpointInterval ) ); } log.infof( "Partitions: %s", (Object) props ); PartitionPlan partitionPlan = new PartitionPlanImpl(); partitionPlan.setPartitionProperties( props ); partitionPlan.setPartitions( partitions ); Integer threads = SerializationUtil.parseIntegerParameterOptional( MAX_THREADS, serializedMaxThreads, null ); if ( threads != null ) { partitionPlan.setThreads( threads ); } log.partitionsPlan( partitionPlan.getPartitions(), partitionPlan.getThreads() ); return partitionPlan; } } | PartitionMapper implements javax.batch.api.partition.PartitionMapper { @Override public PartitionPlan mapPartitions() throws Exception { JobContextData jobData = (JobContextData) jobContext.getTransientUserData(); emf = jobData.getEntityManagerFactory(); try ( StatelessSession ss = PersistenceUtil.openStatelessSession( emf, tenantId ) ) { Integer maxResults = SerializationUtil.parseIntegerParameterOptional( MAX_RESULTS_PER_ENTITY, serializedMaxResultsPerEntity, null ); int rowsPerPartition = SerializationUtil.parseIntegerParameterOptional( ROWS_PER_PARTITION, serializedRowsPerPartition, Defaults.ROWS_PER_PARTITION ); Integer checkpointIntervalRaw = SerializationUtil.parseIntegerParameterOptional( CHECKPOINT_INTERVAL, serializedCheckpointInterval, null ); int checkpointInterval = Defaults.checkpointInterval( checkpointIntervalRaw, rowsPerPartition ); int idFetchSize = SerializationUtil.parseIntegerParameterOptional( ID_FETCH_SIZE, serializedIdFetchSize, Defaults.ID_FETCH_SIZE ); List<EntityTypeDescriptor> entityTypeDescriptors = jobData.getEntityTypeDescriptors(); List<PartitionBound> partitionBounds = new ArrayList<>(); switch ( PersistenceUtil.getIndexScope( customQueryHql, jobData.getCustomQueryCriteria() ) ) { case HQL: Class<?> clazz = entityTypeDescriptors.get( 0 ).getJavaClass(); partitionBounds.add( new PartitionBound( clazz, null, null, IndexScope.HQL ) ); break; case CRITERIA: partitionBounds = buildPartitionUnitsFrom( ss, entityTypeDescriptors.get( 0 ), jobData.getCustomQueryCriteria(), maxResults, idFetchSize, rowsPerPartition, IndexScope.CRITERIA ); break; case FULL_ENTITY: for ( EntityTypeDescriptor entityTypeDescriptor : entityTypeDescriptors ) { partitionBounds.addAll( buildPartitionUnitsFrom( ss, entityTypeDescriptor, Collections.emptySet(), maxResults, idFetchSize, rowsPerPartition, IndexScope.FULL_ENTITY ) ); } break; } final int partitions = partitionBounds.size(); final Properties[] props = new Properties[partitions]; for ( int i = 0; i < partitionBounds.size(); i++ ) { PartitionBound bound = partitionBounds.get( i ); props[i] = new Properties(); props[i].setProperty( MassIndexingPartitionProperties.ENTITY_NAME, bound.getEntityName() ); props[i].setProperty( MassIndexingPartitionProperties.PARTITION_ID, String.valueOf( i ) ); props[i].setProperty( MassIndexingPartitionProperties.LOWER_BOUND, SerializationUtil.serialize( bound.getLowerBound() ) ); props[i].setProperty( MassIndexingPartitionProperties.UPPER_BOUND, SerializationUtil.serialize( bound.getUpperBound() ) ); props[i].setProperty( MassIndexingPartitionProperties.INDEX_SCOPE, bound.getIndexScope().name() ); props[i].setProperty( MassIndexingPartitionProperties.CHECKPOINT_INTERVAL, String.valueOf( checkpointInterval ) ); } log.infof( "Partitions: %s", (Object) props ); PartitionPlan partitionPlan = new PartitionPlanImpl(); partitionPlan.setPartitionProperties( props ); partitionPlan.setPartitions( partitions ); Integer threads = SerializationUtil.parseIntegerParameterOptional( MAX_THREADS, serializedMaxThreads, null ); if ( threads != null ) { partitionPlan.setThreads( threads ); } log.partitionsPlan( partitionPlan.getPartitions(), partitionPlan.getThreads() ); return partitionPlan; } } } | PartitionMapper implements javax.batch.api.partition.PartitionMapper { @Override public PartitionPlan mapPartitions() throws Exception { JobContextData jobData = (JobContextData) jobContext.getTransientUserData(); emf = jobData.getEntityManagerFactory(); try ( StatelessSession ss = PersistenceUtil.openStatelessSession( emf, tenantId ) ) { Integer maxResults = SerializationUtil.parseIntegerParameterOptional( MAX_RESULTS_PER_ENTITY, serializedMaxResultsPerEntity, null ); int rowsPerPartition = SerializationUtil.parseIntegerParameterOptional( ROWS_PER_PARTITION, serializedRowsPerPartition, Defaults.ROWS_PER_PARTITION ); Integer checkpointIntervalRaw = SerializationUtil.parseIntegerParameterOptional( CHECKPOINT_INTERVAL, serializedCheckpointInterval, null ); int checkpointInterval = Defaults.checkpointInterval( checkpointIntervalRaw, rowsPerPartition ); int idFetchSize = SerializationUtil.parseIntegerParameterOptional( ID_FETCH_SIZE, serializedIdFetchSize, Defaults.ID_FETCH_SIZE ); List<EntityTypeDescriptor> entityTypeDescriptors = jobData.getEntityTypeDescriptors(); List<PartitionBound> partitionBounds = new ArrayList<>(); switch ( PersistenceUtil.getIndexScope( customQueryHql, jobData.getCustomQueryCriteria() ) ) { case HQL: Class<?> clazz = entityTypeDescriptors.get( 0 ).getJavaClass(); partitionBounds.add( new PartitionBound( clazz, null, null, IndexScope.HQL ) ); break; case CRITERIA: partitionBounds = buildPartitionUnitsFrom( ss, entityTypeDescriptors.get( 0 ), jobData.getCustomQueryCriteria(), maxResults, idFetchSize, rowsPerPartition, IndexScope.CRITERIA ); break; case FULL_ENTITY: for ( EntityTypeDescriptor entityTypeDescriptor : entityTypeDescriptors ) { partitionBounds.addAll( buildPartitionUnitsFrom( ss, entityTypeDescriptor, Collections.emptySet(), maxResults, idFetchSize, rowsPerPartition, IndexScope.FULL_ENTITY ) ); } break; } final int partitions = partitionBounds.size(); final Properties[] props = new Properties[partitions]; for ( int i = 0; i < partitionBounds.size(); i++ ) { PartitionBound bound = partitionBounds.get( i ); props[i] = new Properties(); props[i].setProperty( MassIndexingPartitionProperties.ENTITY_NAME, bound.getEntityName() ); props[i].setProperty( MassIndexingPartitionProperties.PARTITION_ID, String.valueOf( i ) ); props[i].setProperty( MassIndexingPartitionProperties.LOWER_BOUND, SerializationUtil.serialize( bound.getLowerBound() ) ); props[i].setProperty( MassIndexingPartitionProperties.UPPER_BOUND, SerializationUtil.serialize( bound.getUpperBound() ) ); props[i].setProperty( MassIndexingPartitionProperties.INDEX_SCOPE, bound.getIndexScope().name() ); props[i].setProperty( MassIndexingPartitionProperties.CHECKPOINT_INTERVAL, String.valueOf( checkpointInterval ) ); } log.infof( "Partitions: %s", (Object) props ); PartitionPlan partitionPlan = new PartitionPlanImpl(); partitionPlan.setPartitionProperties( props ); partitionPlan.setPartitions( partitions ); Integer threads = SerializationUtil.parseIntegerParameterOptional( MAX_THREADS, serializedMaxThreads, null ); if ( threads != null ) { partitionPlan.setThreads( threads ); } log.partitionsPlan( partitionPlan.getPartitions(), partitionPlan.getThreads() ); return partitionPlan; } } PartitionMapper(); PartitionMapper(
String serializedIdFetchSize,
String customQueryHql,
String serializedMaxThreads,
String serializedMaxResultsPerEntity,
String serializedRowsPerPartition,
String serializedCheckpointInterval,
String tenantId,
JobContext jobContext); } | PartitionMapper implements javax.batch.api.partition.PartitionMapper { @Override public PartitionPlan mapPartitions() throws Exception { JobContextData jobData = (JobContextData) jobContext.getTransientUserData(); emf = jobData.getEntityManagerFactory(); try ( StatelessSession ss = PersistenceUtil.openStatelessSession( emf, tenantId ) ) { Integer maxResults = SerializationUtil.parseIntegerParameterOptional( MAX_RESULTS_PER_ENTITY, serializedMaxResultsPerEntity, null ); int rowsPerPartition = SerializationUtil.parseIntegerParameterOptional( ROWS_PER_PARTITION, serializedRowsPerPartition, Defaults.ROWS_PER_PARTITION ); Integer checkpointIntervalRaw = SerializationUtil.parseIntegerParameterOptional( CHECKPOINT_INTERVAL, serializedCheckpointInterval, null ); int checkpointInterval = Defaults.checkpointInterval( checkpointIntervalRaw, rowsPerPartition ); int idFetchSize = SerializationUtil.parseIntegerParameterOptional( ID_FETCH_SIZE, serializedIdFetchSize, Defaults.ID_FETCH_SIZE ); List<EntityTypeDescriptor> entityTypeDescriptors = jobData.getEntityTypeDescriptors(); List<PartitionBound> partitionBounds = new ArrayList<>(); switch ( PersistenceUtil.getIndexScope( customQueryHql, jobData.getCustomQueryCriteria() ) ) { case HQL: Class<?> clazz = entityTypeDescriptors.get( 0 ).getJavaClass(); partitionBounds.add( new PartitionBound( clazz, null, null, IndexScope.HQL ) ); break; case CRITERIA: partitionBounds = buildPartitionUnitsFrom( ss, entityTypeDescriptors.get( 0 ), jobData.getCustomQueryCriteria(), maxResults, idFetchSize, rowsPerPartition, IndexScope.CRITERIA ); break; case FULL_ENTITY: for ( EntityTypeDescriptor entityTypeDescriptor : entityTypeDescriptors ) { partitionBounds.addAll( buildPartitionUnitsFrom( ss, entityTypeDescriptor, Collections.emptySet(), maxResults, idFetchSize, rowsPerPartition, IndexScope.FULL_ENTITY ) ); } break; } final int partitions = partitionBounds.size(); final Properties[] props = new Properties[partitions]; for ( int i = 0; i < partitionBounds.size(); i++ ) { PartitionBound bound = partitionBounds.get( i ); props[i] = new Properties(); props[i].setProperty( MassIndexingPartitionProperties.ENTITY_NAME, bound.getEntityName() ); props[i].setProperty( MassIndexingPartitionProperties.PARTITION_ID, String.valueOf( i ) ); props[i].setProperty( MassIndexingPartitionProperties.LOWER_BOUND, SerializationUtil.serialize( bound.getLowerBound() ) ); props[i].setProperty( MassIndexingPartitionProperties.UPPER_BOUND, SerializationUtil.serialize( bound.getUpperBound() ) ); props[i].setProperty( MassIndexingPartitionProperties.INDEX_SCOPE, bound.getIndexScope().name() ); props[i].setProperty( MassIndexingPartitionProperties.CHECKPOINT_INTERVAL, String.valueOf( checkpointInterval ) ); } log.infof( "Partitions: %s", (Object) props ); PartitionPlan partitionPlan = new PartitionPlanImpl(); partitionPlan.setPartitionProperties( props ); partitionPlan.setPartitions( partitions ); Integer threads = SerializationUtil.parseIntegerParameterOptional( MAX_THREADS, serializedMaxThreads, null ); if ( threads != null ) { partitionPlan.setThreads( threads ); } log.partitionsPlan( partitionPlan.getPartitions(), partitionPlan.getThreads() ); return partitionPlan; } } PartitionMapper(); PartitionMapper(
String serializedIdFetchSize,
String customQueryHql,
String serializedMaxThreads,
String serializedMaxResultsPerEntity,
String serializedRowsPerPartition,
String serializedCheckpointInterval,
String tenantId,
JobContext jobContext); @Override PartitionPlan mapPartitions(); } | PartitionMapper implements javax.batch.api.partition.PartitionMapper { @Override public PartitionPlan mapPartitions() throws Exception { JobContextData jobData = (JobContextData) jobContext.getTransientUserData(); emf = jobData.getEntityManagerFactory(); try ( StatelessSession ss = PersistenceUtil.openStatelessSession( emf, tenantId ) ) { Integer maxResults = SerializationUtil.parseIntegerParameterOptional( MAX_RESULTS_PER_ENTITY, serializedMaxResultsPerEntity, null ); int rowsPerPartition = SerializationUtil.parseIntegerParameterOptional( ROWS_PER_PARTITION, serializedRowsPerPartition, Defaults.ROWS_PER_PARTITION ); Integer checkpointIntervalRaw = SerializationUtil.parseIntegerParameterOptional( CHECKPOINT_INTERVAL, serializedCheckpointInterval, null ); int checkpointInterval = Defaults.checkpointInterval( checkpointIntervalRaw, rowsPerPartition ); int idFetchSize = SerializationUtil.parseIntegerParameterOptional( ID_FETCH_SIZE, serializedIdFetchSize, Defaults.ID_FETCH_SIZE ); List<EntityTypeDescriptor> entityTypeDescriptors = jobData.getEntityTypeDescriptors(); List<PartitionBound> partitionBounds = new ArrayList<>(); switch ( PersistenceUtil.getIndexScope( customQueryHql, jobData.getCustomQueryCriteria() ) ) { case HQL: Class<?> clazz = entityTypeDescriptors.get( 0 ).getJavaClass(); partitionBounds.add( new PartitionBound( clazz, null, null, IndexScope.HQL ) ); break; case CRITERIA: partitionBounds = buildPartitionUnitsFrom( ss, entityTypeDescriptors.get( 0 ), jobData.getCustomQueryCriteria(), maxResults, idFetchSize, rowsPerPartition, IndexScope.CRITERIA ); break; case FULL_ENTITY: for ( EntityTypeDescriptor entityTypeDescriptor : entityTypeDescriptors ) { partitionBounds.addAll( buildPartitionUnitsFrom( ss, entityTypeDescriptor, Collections.emptySet(), maxResults, idFetchSize, rowsPerPartition, IndexScope.FULL_ENTITY ) ); } break; } final int partitions = partitionBounds.size(); final Properties[] props = new Properties[partitions]; for ( int i = 0; i < partitionBounds.size(); i++ ) { PartitionBound bound = partitionBounds.get( i ); props[i] = new Properties(); props[i].setProperty( MassIndexingPartitionProperties.ENTITY_NAME, bound.getEntityName() ); props[i].setProperty( MassIndexingPartitionProperties.PARTITION_ID, String.valueOf( i ) ); props[i].setProperty( MassIndexingPartitionProperties.LOWER_BOUND, SerializationUtil.serialize( bound.getLowerBound() ) ); props[i].setProperty( MassIndexingPartitionProperties.UPPER_BOUND, SerializationUtil.serialize( bound.getUpperBound() ) ); props[i].setProperty( MassIndexingPartitionProperties.INDEX_SCOPE, bound.getIndexScope().name() ); props[i].setProperty( MassIndexingPartitionProperties.CHECKPOINT_INTERVAL, String.valueOf( checkpointInterval ) ); } log.infof( "Partitions: %s", (Object) props ); PartitionPlan partitionPlan = new PartitionPlanImpl(); partitionPlan.setPartitionProperties( props ); partitionPlan.setPartitions( partitions ); Integer threads = SerializationUtil.parseIntegerParameterOptional( MAX_THREADS, serializedMaxThreads, null ); if ( threads != null ) { partitionPlan.setThreads( threads ); } log.partitionsPlan( partitionPlan.getPartitions(), partitionPlan.getThreads() ); return partitionPlan; } } PartitionMapper(); PartitionMapper(
String serializedIdFetchSize,
String customQueryHql,
String serializedMaxThreads,
String serializedMaxResultsPerEntity,
String serializedRowsPerPartition,
String serializedCheckpointInterval,
String tenantId,
JobContext jobContext); @Override PartitionPlan mapPartitions(); } |
@Test public void exactType() { PojoRawTypeModel typeToMatchMock = mock( PojoRawTypeModel.class ); PojoGenericTypeModel typeToInspectMock = mock( PojoGenericTypeModel.class ); PojoRawTypeModel typeToInspectRawTypeMock = mock( PojoRawTypeModel.class ); when( introspectorMock.typeModel( String.class ) ) .thenReturn( typeToMatchMock ); TypePatternMatcher matcher = factory.createExactRawTypeMatcher( String.class ); assertThat( matcher ).isNotNull(); when( typeToMatchMock.name() ) .thenReturn( "THE_TYPE_TO_MATCH" ); assertThat( matcher.toString() ) .isEqualTo( "hasExactRawType(THE_TYPE_TO_MATCH)" ); when( typeToInspectMock.rawType() ) .thenReturn( typeToInspectRawTypeMock ); when( typeToMatchMock.isSubTypeOf( typeToInspectRawTypeMock ) ) .thenReturn( true ); when( typeToInspectRawTypeMock.isSubTypeOf( typeToMatchMock ) ) .thenReturn( true ); assertThat( matcher.matches( typeToInspectMock ) ).isTrue(); when( typeToMatchMock.isSubTypeOf( typeToInspectRawTypeMock ) ) .thenReturn( false ); when( typeToInspectRawTypeMock.isSubTypeOf( typeToMatchMock ) ) .thenReturn( true ); assertThat( matcher.matches( typeToInspectMock ) ).isFalse(); when( typeToMatchMock.isSubTypeOf( typeToInspectRawTypeMock ) ) .thenReturn( true ); when( typeToInspectRawTypeMock.isSubTypeOf( typeToMatchMock ) ) .thenReturn( false ); assertThat( matcher.matches( typeToInspectMock ) ).isFalse(); when( typeToMatchMock.isSubTypeOf( typeToInspectRawTypeMock ) ) .thenReturn( false ); when( typeToInspectRawTypeMock.isSubTypeOf( typeToMatchMock ) ) .thenReturn( false ); assertThat( matcher.matches( typeToInspectMock ) ).isFalse(); } | public TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch) { PojoRawTypeModel<?> exactTypeToMatchModel = introspector.typeModel( exactTypeToMatch ); return new ExactRawTypeMatcher( exactTypeToMatchModel ); } | TypePatternMatcherFactory { public TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch) { PojoRawTypeModel<?> exactTypeToMatchModel = introspector.typeModel( exactTypeToMatch ); return new ExactRawTypeMatcher( exactTypeToMatchModel ); } } | TypePatternMatcherFactory { public TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch) { PojoRawTypeModel<?> exactTypeToMatchModel = introspector.typeModel( exactTypeToMatch ); return new ExactRawTypeMatcher( exactTypeToMatchModel ); } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch) { PojoRawTypeModel<?> exactTypeToMatchModel = introspector.typeModel( exactTypeToMatch ); return new ExactRawTypeMatcher( exactTypeToMatchModel ); } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch) { PojoRawTypeModel<?> exactTypeToMatchModel = introspector.typeModel( exactTypeToMatch ); return new ExactRawTypeMatcher( exactTypeToMatchModel ); } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public void wildcardType() { assertThatThrownBy( () -> factory.createExtractingMatcher( new WildcardTypeCapture<Of<?>>() { }.getType(), String.class ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T> void typeVariable() { Type type = new TypeCapture<T>() { }.getType(); assertThatThrownBy( () -> factory.createExtractingMatcher( type, String.class ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public void rawSuperType() { PojoRawTypeModel<String> typeToMatchMock = mock( PojoRawTypeModel.class ); PojoGenericTypeModel<Integer> resultTypeMock = mock( PojoGenericTypeModel.class ); PojoGenericTypeModel<?> typeToInspectMock = mock( PojoGenericTypeModel.class ); PojoRawTypeModel typeToInspectRawTypeMock = mock( PojoRawTypeModel.class ); when( introspectorMock.typeModel( String.class ) ) .thenReturn( typeToMatchMock ); when( introspectorMock.genericTypeModel( Integer.class ) ) .thenReturn( resultTypeMock ); ExtractingTypePatternMatcher matcher = factory.createExtractingMatcher( String.class, Integer.class ); assertThat( matcher ).isNotNull(); when( typeToMatchMock.name() ) .thenReturn( "THE_TYPE_TO_MATCH" ); when( resultTypeMock.name() ) .thenReturn( "THE_RESULT_TYPE" ); assertThat( matcher.toString() ) .isEqualTo( "hasRawSuperType(THE_TYPE_TO_MATCH) => THE_RESULT_TYPE" ); Optional<? extends PojoGenericTypeModel<?>> actualReturn; when( typeToInspectMock.rawType() ) .thenReturn( typeToInspectRawTypeMock ); when( typeToInspectRawTypeMock.isSubTypeOf( typeToMatchMock ) ) .thenReturn( true ); actualReturn = matcher.extract( typeToInspectMock ); assertThat( actualReturn ).isNotNull(); assertThat( actualReturn.isPresent() ).isTrue(); assertThat( actualReturn.get() ).isSameAs( resultTypeMock ); when( typeToInspectRawTypeMock.isSubTypeOf( typeToMatchMock ) ) .thenReturn( false ); actualReturn = matcher.extract( typeToInspectMock ); assertThat( actualReturn ).isNotNull(); assertThat( actualReturn.isPresent() ).isFalse(); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public void toLiteral() { assertThat( pattern.toLiteral() ).isEqualTo( expectedToLiteral ); } | public Optional<String> toLiteral() { return Optional.empty(); } | SimpleGlobPattern { public Optional<String> toLiteral() { return Optional.empty(); } } | SimpleGlobPattern { public Optional<String> toLiteral() { return Optional.empty(); } private SimpleGlobPattern(); } | SimpleGlobPattern { public Optional<String> toLiteral() { return Optional.empty(); } private SimpleGlobPattern(); static SimpleGlobPattern compile(String patternString); boolean matches(String candidate); SimpleGlobPattern prependLiteral(String literal); SimpleGlobPattern prependMany(); Optional<String> toLiteral(); abstract String toPatternString(); } | SimpleGlobPattern { public Optional<String> toLiteral() { return Optional.empty(); } private SimpleGlobPattern(); static SimpleGlobPattern compile(String patternString); boolean matches(String candidate); SimpleGlobPattern prependLiteral(String literal); SimpleGlobPattern prependMany(); Optional<String> toLiteral(); abstract String toPatternString(); } |
@Test public <T> void rawSuperType_resultIsTypeVariable() { assertThatThrownBy( () -> factory.createExtractingMatcher( String.class, new TypeCapture<T>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T> void rawSuperType_resultIsWildcard() { assertThatThrownBy( () -> factory.createExtractingMatcher( String.class, new WildcardTypeCapture<Of<?>>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public void rawSuperType_resultIsParameterized() { assertThatThrownBy( () -> factory.createExtractingMatcher( String.class, new TypeCapture<List<String>>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public void nonGenericArrayElement() { PojoRawTypeModel<String[]> typeToMatchMock = mock( PojoRawTypeModel.class ); PojoGenericTypeModel<Integer> resultTypeMock = mock( PojoGenericTypeModel.class ); PojoGenericTypeModel<?> typeToInspectMock = mock( PojoGenericTypeModel.class ); PojoRawTypeModel typeToInspectRawTypeMock = mock( PojoRawTypeModel.class ); when( introspectorMock.typeModel( String[].class ) ) .thenReturn( typeToMatchMock ); when( introspectorMock.genericTypeModel( Integer.class ) ) .thenReturn( resultTypeMock ); ExtractingTypePatternMatcher matcher = factory.createExtractingMatcher( String[].class, Integer.class ); assertThat( matcher ).isNotNull(); when( typeToMatchMock.name() ) .thenReturn( "THE_TYPE_TO_MATCH" ); when( resultTypeMock.name() ) .thenReturn( "THE_RESULT_TYPE" ); assertThat( matcher.toString() ) .isEqualTo( "hasRawSuperType(THE_TYPE_TO_MATCH) => THE_RESULT_TYPE" ); Optional<? extends PojoGenericTypeModel<?>> actualReturn; when( typeToInspectMock.rawType() ) .thenReturn( typeToInspectRawTypeMock ); when( typeToInspectRawTypeMock.isSubTypeOf( typeToMatchMock ) ) .thenReturn( true ); actualReturn = matcher.extract( typeToInspectMock ); assertThat( actualReturn ).isNotNull(); assertThat( actualReturn.isPresent() ).isTrue(); assertThat( actualReturn.get() ).isSameAs( resultTypeMock ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T> void genericArrayElement() { PojoGenericTypeModel<?> typeToInspectMock = mock( PojoGenericTypeModel.class ); PojoGenericTypeModel<T> resultTypeMock = mock( PojoGenericTypeModel.class ); ExtractingTypePatternMatcher matcher = factory.createExtractingMatcher( new TypeCapture<T[]>() { }.getType(), new TypeCapture<T>() { }.getType() ); assertThat( matcher ).isInstanceOf( ArrayElementTypeMatcher.class ); assertThat( matcher.toString() ) .isEqualTo( "T[] => T" ); Optional<? extends PojoGenericTypeModel<?>> actualReturn; when( typeToInspectMock.arrayElementType() ) .thenReturn( (Optional) Optional.of( resultTypeMock ) ); actualReturn = matcher.extract( typeToInspectMock ); assertThat( actualReturn ).isNotNull(); assertThat( actualReturn.isPresent() ).isTrue(); assertThat( actualReturn.get() ).isSameAs( resultTypeMock ); when( typeToInspectMock.arrayElementType() ) .thenReturn( Optional.empty() ); actualReturn = matcher.extract( typeToInspectMock ); assertThat( actualReturn ).isNotNull(); assertThat( actualReturn.isPresent() ).isFalse(); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T extends Iterable<?>> void genericArrayElement_boundedTypeVariable() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<T[]>() { }.getType(), new TypeCapture<T>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T extends Object & Serializable> void genericArrayElement_multiBoundedTypeVariable() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<T[]>() { }.getType(), new TypeCapture<T>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T> void genericArrayElement_resultIsRawType() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<T[]>() { }.getType(), Object.class ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T, U> void genericArrayElement_resultIsDifferentTypeArgument() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<T[]>() { }.getType(), new TypeCapture<U>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T> void parameterizedType() { PojoGenericTypeModel<?> typeToInspectMock = mock( PojoGenericTypeModel.class ); PojoGenericTypeModel<Integer> resultTypeMock = mock( PojoGenericTypeModel.class ); ExtractingTypePatternMatcher matcher = factory.createExtractingMatcher( new TypeCapture<Map<?, T>>() { }.getType(), new TypeCapture<T>() { }.getType() ); assertThat( matcher ).isInstanceOf( ParameterizedTypeArgumentMatcher.class ); assertThat( matcher.toString() ) .isEqualTo( "java.util.Map<?, T> => T" ); Optional<? extends PojoGenericTypeModel<?>> actualReturn; when( typeToInspectMock.typeArgument( Map.class, 1 ) ) .thenReturn( (Optional) Optional.of( resultTypeMock ) ); actualReturn = matcher.extract( typeToInspectMock ); assertThat( actualReturn ).isNotNull(); assertThat( actualReturn.isPresent() ).isTrue(); assertThat( actualReturn.get() ).isSameAs( resultTypeMock ); when( typeToInspectMock.typeArgument( Map.class, 1 ) ) .thenReturn( Optional.empty() ); actualReturn = matcher.extract( typeToInspectMock ); assertThat( actualReturn ).isNotNull(); assertThat( actualReturn.isPresent() ).isFalse(); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public void runnable_cancel() throws InterruptedException { AtomicBoolean started = new AtomicBoolean( false ); AtomicBoolean finished = new AtomicBoolean( false ); CompletableFuture<Void> future = new CancellableExecutionCompletableFuture<>( () -> { started.set( true ); try { Thread.sleep( Long.MAX_VALUE ); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException( e ); } finally { finished.set( true ); } }, executorService ); Awaitility.await().untilTrue( started ); Awaitility.await().untilAsserted( () -> assertThat( future.cancel( true ) ).isTrue() ); Awaitility.await().until( future::isDone ); assertThatFuture( future ).isCancelled(); Awaitility.await().untilTrue( finished ); Awaitility.await().untilAsserted( () -> assertThat( Futures.getThrowableNow( future ) ) .extracting( Throwable::getSuppressed ).asInstanceOf( InstanceOfAssertFactories.ARRAY ) .hasSize( 1 ) .extracting( Function.identity() ) .first() .asInstanceOf( InstanceOfAssertFactories.THROWABLE ) .isInstanceOf( RuntimeException.class ) .hasCauseInstanceOf( InterruptedException.class ) ); } | @Override public boolean cancel(boolean mayInterruptIfRunning) { super.cancel( mayInterruptIfRunning ); return future.cancel( mayInterruptIfRunning ); } | CancellableExecutionCompletableFuture extends CompletableFuture<T> { @Override public boolean cancel(boolean mayInterruptIfRunning) { super.cancel( mayInterruptIfRunning ); return future.cancel( mayInterruptIfRunning ); } } | CancellableExecutionCompletableFuture extends CompletableFuture<T> { @Override public boolean cancel(boolean mayInterruptIfRunning) { super.cancel( mayInterruptIfRunning ); return future.cancel( mayInterruptIfRunning ); } CancellableExecutionCompletableFuture(Runnable runnable, ExecutorService executor); } | CancellableExecutionCompletableFuture extends CompletableFuture<T> { @Override public boolean cancel(boolean mayInterruptIfRunning) { super.cancel( mayInterruptIfRunning ); return future.cancel( mayInterruptIfRunning ); } CancellableExecutionCompletableFuture(Runnable runnable, ExecutorService executor); @Override boolean cancel(boolean mayInterruptIfRunning); } | CancellableExecutionCompletableFuture extends CompletableFuture<T> { @Override public boolean cancel(boolean mayInterruptIfRunning) { super.cancel( mayInterruptIfRunning ); return future.cancel( mayInterruptIfRunning ); } CancellableExecutionCompletableFuture(Runnable runnable, ExecutorService executor); @Override boolean cancel(boolean mayInterruptIfRunning); } |
@Test public <T> void parameterizedType_upperBoundedWildcard() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<Map<? extends Long, T>>() { }.getType(), new TypeCapture<T>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T> void parameterizedType_lowerBoundedWildcard() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<Map<? super Long, T>>() { }.getType(), new TypeCapture<T>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T> void parameterizedType_onlyWildcards() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<Map<?, ?>>() { }.getType(), new TypeCapture<T>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T> void parameterizedType_rawType() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<Map<?, String>>() { }.getType(), new TypeCapture<T>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T extends Iterable<?>> void parameterizedType_boundedTypeVariable() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<Map<?, T>>() { }.getType(), new TypeCapture<T>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T extends Object & Serializable> void parameterizedType_multiBoundedTypeVariable() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<Map<?, T>>() { }.getType(), new TypeCapture<T>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T, U> void parameterizedType_multipleTypeVariables() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<Map<T, U>>() { }.getType(), new TypeCapture<T>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T, U> void parameterizedType_resultIsRawType() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<Map<?, T>>() { }.getType(), Object.class ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public <T, U> void parameterizedType_resultIsDifferentTypeArgument() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture<Map<?, T>>() { }.getType(), new TypeCapture<U>() { }.getType() ) ) .isInstanceOf( UnsupportedOperationException.class ); } | public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } | TypePatternMatcherFactory { public ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract) { if ( typePattern instanceof TypeVariable ) { throw new UnsupportedOperationException( "Matching a type variable is not supported" ); } else if ( typePattern instanceof WildcardType ) { throw new UnsupportedOperationException( "Matching a wildcard type is not supported" ); } else if ( typePattern instanceof ParameterizedType ) { ParameterizedType parameterizedTypePattern = (ParameterizedType) typePattern; return createExtractingParameterizedTypeMatcher( parameterizedTypePattern, typeToExtract ); } else if ( typePattern instanceof Class ) { Class<?> classTypePattern = (Class<?>) typePattern; return createExtractingClassTypeMatcher( classTypePattern, typeToExtract ); } else if ( typePattern instanceof GenericArrayType ) { GenericArrayType arrayTypePattern = (GenericArrayType) typePattern; return createExtractingGenericArrayTypeMatcher( arrayTypePattern, typeToExtract ); } else { throw new AssertionFailure( "Unexpected java.lang.reflect.Type type: " + typePattern.getClass() ); } } TypePatternMatcherFactory(PojoBootstrapIntrospector introspector); TypePatternMatcher createExactRawTypeMatcher(Class<?> exactTypeToMatch); TypePatternMatcher createRawSuperTypeMatcher(Class<?> superTypeToMatch); ExtractingTypePatternMatcher createExtractingMatcher(Type typePattern, Type typeToExtract); } |
@Test public void ofProperty() { assertThat( PojoModelPath.ofProperty( "foo" ) ) .satisfies( isPath( "foo" ) ); assertThatThrownBy( () -> PojoModelPath.ofProperty( null ) ) .isInstanceOf( IllegalArgumentException.class ); assertThatThrownBy( () -> PojoModelPath.ofProperty( "" ) ) .isInstanceOf( IllegalArgumentException.class ); } | public static PojoModelPathPropertyNode ofProperty(String propertyName) { return new PojoModelPathPropertyNode( null, propertyName ); } | PojoModelPath { public static PojoModelPathPropertyNode ofProperty(String propertyName) { return new PojoModelPathPropertyNode( null, propertyName ); } } | PojoModelPath { public static PojoModelPathPropertyNode ofProperty(String propertyName) { return new PojoModelPathPropertyNode( null, propertyName ); } PojoModelPath(); } | PojoModelPath { public static PojoModelPathPropertyNode ofProperty(String propertyName) { return new PojoModelPathPropertyNode( null, propertyName ); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } | PojoModelPath { public static PojoModelPathPropertyNode ofProperty(String propertyName) { return new PojoModelPathPropertyNode( null, propertyName ); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } |
@Test public void split() { MyException1 exception1 = new MyException1(); MyException2 exception2 = new MyException2(); IOException exception3 = new IOException(); assertThatThrownBy( () -> { try ( Closer<IOException> closer1 = new Closer<>(); Closer<MyException1> closer2 = closer1.split(); Closer<MyException2> closer3 = closer1.split() ) { closer2.push( ignored -> { throw exception1; }, new Object() ); closer3.push( ignored -> { throw exception2; }, new Object() ); closer1.push( ignored -> { throw exception3; }, new Object() ); } } ) .isSameAs( exception1 ) .hasSuppressedException( exception2 ) .hasSuppressedException( exception3 ); } | public <E2 extends Exception> Closer<E2> split() { return new Closer<>( state ); } | Closer extends AbstractCloser<Closer<E>, E> implements AutoCloseable { public <E2 extends Exception> Closer<E2> split() { return new Closer<>( state ); } } | Closer extends AbstractCloser<Closer<E>, E> implements AutoCloseable { public <E2 extends Exception> Closer<E2> split() { return new Closer<>( state ); } Closer(); private Closer(CloseableState state); } | Closer extends AbstractCloser<Closer<E>, E> implements AutoCloseable { public <E2 extends Exception> Closer<E2> split() { return new Closer<>( state ); } Closer(); private Closer(CloseableState state); Closer<E2> split(); @Override void close(); } | Closer extends AbstractCloser<Closer<E>, E> implements AutoCloseable { public <E2 extends Exception> Closer<E2> split() { return new Closer<>( state ); } Closer(); private Closer(CloseableState state); Closer<E2> split(); @Override void close(); } |
@Test public void ofValue_property() { assertThat( PojoModelPath.ofValue( "foo" ) ) .satisfies( isPath( "foo", ContainerExtractorPath.defaultExtractors() ) ); assertThatThrownBy( () -> PojoModelPath.ofValue( null ) ) .isInstanceOf( IllegalArgumentException.class ); assertThatThrownBy( () -> PojoModelPath.ofValue( "" ) ) .isInstanceOf( IllegalArgumentException.class ); } | public static PojoModelPathValueNode ofValue(String propertyName) { return ofValue( propertyName, ContainerExtractorPath.defaultExtractors() ); } | PojoModelPath { public static PojoModelPathValueNode ofValue(String propertyName) { return ofValue( propertyName, ContainerExtractorPath.defaultExtractors() ); } } | PojoModelPath { public static PojoModelPathValueNode ofValue(String propertyName) { return ofValue( propertyName, ContainerExtractorPath.defaultExtractors() ); } PojoModelPath(); } | PojoModelPath { public static PojoModelPathValueNode ofValue(String propertyName) { return ofValue( propertyName, ContainerExtractorPath.defaultExtractors() ); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } | PojoModelPath { public static PojoModelPathValueNode ofValue(String propertyName) { return ofValue( propertyName, ContainerExtractorPath.defaultExtractors() ); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } |
@Test public void ofValue_propertyAndContainerExtractorPath() { assertThat( PojoModelPath.ofValue( "foo", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.MAP_KEY ) ) ) .satisfies( isPath( "foo", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.MAP_KEY ) ) ); assertThatThrownBy( () -> PojoModelPath.ofValue( null, ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.MAP_KEY ) ) ) .isInstanceOf( IllegalArgumentException.class ); assertThatThrownBy( () -> PojoModelPath.ofValue( "", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.MAP_KEY ) ) ) .isInstanceOf( IllegalArgumentException.class ); assertThatThrownBy( () -> PojoModelPath.ofValue( "foo", null ) ) .isInstanceOf( IllegalArgumentException.class ); } | public static PojoModelPathValueNode ofValue(String propertyName) { return ofValue( propertyName, ContainerExtractorPath.defaultExtractors() ); } | PojoModelPath { public static PojoModelPathValueNode ofValue(String propertyName) { return ofValue( propertyName, ContainerExtractorPath.defaultExtractors() ); } } | PojoModelPath { public static PojoModelPathValueNode ofValue(String propertyName) { return ofValue( propertyName, ContainerExtractorPath.defaultExtractors() ); } PojoModelPath(); } | PojoModelPath { public static PojoModelPathValueNode ofValue(String propertyName) { return ofValue( propertyName, ContainerExtractorPath.defaultExtractors() ); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } | PojoModelPath { public static PojoModelPathValueNode ofValue(String propertyName) { return ofValue( propertyName, ContainerExtractorPath.defaultExtractors() ); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } |
@Test public void parse() { assertThat( PojoModelPath.parse( "foo" ) ) .satisfies( isPath( "foo", ContainerExtractorPath.defaultExtractors() ) ); assertThat( PojoModelPath.parse( "foo.bar" ) ) .satisfies( isPath( "foo", ContainerExtractorPath.defaultExtractors(), "bar", ContainerExtractorPath.defaultExtractors() ) ); assertThatThrownBy( () -> PojoModelPath.parse( null ) ) .isInstanceOf( IllegalArgumentException.class ); assertThatThrownBy( () -> PojoModelPath.parse( "" ) ) .isInstanceOf( IllegalArgumentException.class ); assertThatThrownBy( () -> PojoModelPath.parse( "foo..bar" ) ) .isInstanceOf( IllegalArgumentException.class ); assertThatThrownBy( () -> PojoModelPath.parse( "foo." ) ) .isInstanceOf( IllegalArgumentException.class ); } | public static PojoModelPathValueNode parse(String dotSeparatedPath) { Contracts.assertNotNullNorEmpty( dotSeparatedPath, "dotSeparatedPath" ); Builder builder = builder(); for ( String propertyName : DOT_PATTERN.split( dotSeparatedPath, -1 ) ) { builder.property( propertyName ).valueWithDefaultExtractors(); } return builder.toValuePath(); } | PojoModelPath { public static PojoModelPathValueNode parse(String dotSeparatedPath) { Contracts.assertNotNullNorEmpty( dotSeparatedPath, "dotSeparatedPath" ); Builder builder = builder(); for ( String propertyName : DOT_PATTERN.split( dotSeparatedPath, -1 ) ) { builder.property( propertyName ).valueWithDefaultExtractors(); } return builder.toValuePath(); } } | PojoModelPath { public static PojoModelPathValueNode parse(String dotSeparatedPath) { Contracts.assertNotNullNorEmpty( dotSeparatedPath, "dotSeparatedPath" ); Builder builder = builder(); for ( String propertyName : DOT_PATTERN.split( dotSeparatedPath, -1 ) ) { builder.property( propertyName ).valueWithDefaultExtractors(); } return builder.toValuePath(); } PojoModelPath(); } | PojoModelPath { public static PojoModelPathValueNode parse(String dotSeparatedPath) { Contracts.assertNotNullNorEmpty( dotSeparatedPath, "dotSeparatedPath" ); Builder builder = builder(); for ( String propertyName : DOT_PATTERN.split( dotSeparatedPath, -1 ) ) { builder.property( propertyName ).valueWithDefaultExtractors(); } return builder.toValuePath(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } | PojoModelPath { public static PojoModelPathValueNode parse(String dotSeparatedPath) { Contracts.assertNotNullNorEmpty( dotSeparatedPath, "dotSeparatedPath" ); Builder builder = builder(); for ( String propertyName : DOT_PATTERN.split( dotSeparatedPath, -1 ) ) { builder.property( propertyName ).valueWithDefaultExtractors(); } return builder.toValuePath(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } |
@Test public void builder() { PojoModelPath.Builder builder = PojoModelPath.builder(); builder.property( "foo" ).value( BuiltinContainerExtractors.COLLECTION ) .property( "bar" ).valueWithoutExtractors() .property( "fubar" ).valueWithDefaultExtractors() .property( "other" ).value( BuiltinContainerExtractors.MAP_KEY ) .property( "other2" ).value( ContainerExtractorPath.defaultExtractors() ) .property( "other3" ).value( ContainerExtractorPath.noExtractors() ) .property( "other4" ).value( ContainerExtractorPath.explicitExtractors( Arrays.asList( BuiltinContainerExtractors.ITERABLE, BuiltinContainerExtractors.OPTIONAL_DOUBLE ) ) ); assertThat( builder.toValuePath() ) .satisfies( isPath( "foo", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.COLLECTION ), "bar", ContainerExtractorPath.noExtractors(), "fubar", ContainerExtractorPath.defaultExtractors(), "other", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.MAP_KEY ), "other2", ContainerExtractorPath.defaultExtractors(), "other3", ContainerExtractorPath.noExtractors(), "other4", ContainerExtractorPath.explicitExtractors( Arrays.asList( BuiltinContainerExtractors.ITERABLE, BuiltinContainerExtractors.OPTIONAL_DOUBLE ) ) ) ); builder = PojoModelPath.builder(); builder.property( "foo" ).value( BuiltinContainerExtractors.COLLECTION ) .property( "bar" ).value( BuiltinContainerExtractors.MAP_KEY ); assertThat( builder.toPropertyPath() ) .satisfies( isPath( "foo", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.COLLECTION ), "bar" ) ); } | public static Builder builder() { return new Builder(); } | PojoModelPath { public static Builder builder() { return new Builder(); } } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } |
@Test public void builder_missingContainerExtractorPath_middle() { PojoModelPath.Builder builder = PojoModelPath.builder(); builder.property( "foo" ).property( "bar" ).value( BuiltinContainerExtractors.MAP_KEY ); assertThat( builder.toValuePath() ) .satisfies( isPath( "foo", ContainerExtractorPath.defaultExtractors(), "bar", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.MAP_KEY ) ) ); } | public static Builder builder() { return new Builder(); } | PojoModelPath { public static Builder builder() { return new Builder(); } } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } |
@Test public void builder_missingContainerExtractorPath_end() { PojoModelPath.Builder builder = PojoModelPath.builder(); builder.property( "foo" ).value( BuiltinContainerExtractors.COLLECTION ).property( "bar" ); assertThat( builder.toValuePath() ) .satisfies( isPath( "foo", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.COLLECTION ), "bar", ContainerExtractorPath.defaultExtractors() ) ); builder = PojoModelPath.builder(); builder.property( "foo" ).value( BuiltinContainerExtractors.COLLECTION ).property( "bar" ); assertThat( builder.toPropertyPath() ) .satisfies( isPath( "foo", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.COLLECTION ), "bar" ) ); } | public static Builder builder() { return new Builder(); } | PojoModelPath { public static Builder builder() { return new Builder(); } } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } |
@Test public void builder_missingPropertyName() { assertThat( PojoModelPath.builder().toValuePathOrNull() ).isNull(); assertThat( PojoModelPath.builder().toPropertyPathOrNull() ).isNull(); String errorMessage = "A PojoModelPath must include at least one property"; assertThatThrownBy( () -> PojoModelPath.builder().toValuePath() ) .isInstanceOf( SearchException.class ) .hasMessageContaining( errorMessage ); assertThatThrownBy( () -> PojoModelPath.builder().toPropertyPath() ) .isInstanceOf( SearchException.class ) .hasMessageContaining( errorMessage ); assertThatThrownBy( () -> PojoModelPath.builder().value( BuiltinContainerExtractors.COLLECTION ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( errorMessage ); assertThatThrownBy( () -> PojoModelPath.builder().valueWithoutExtractors() ) .isInstanceOf( SearchException.class ) .hasMessageContaining( errorMessage ); assertThatThrownBy( () -> PojoModelPath.builder().valueWithDefaultExtractors() ) .isInstanceOf( SearchException.class ) .hasMessageContaining( errorMessage ); } | public static Builder builder() { return new Builder(); } | PojoModelPath { public static Builder builder() { return new Builder(); } } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } |
@Test public void builder_chainedContainerExtractors() { PojoModelPath.Builder builder = PojoModelPath.builder(); builder.property( "foo" ).value( BuiltinContainerExtractors.COLLECTION ).value( BuiltinContainerExtractors.ITERABLE ) .property( "bar" ).value( BuiltinContainerExtractors.MAP_KEY ); assertThat( builder.toValuePath() ) .satisfies( isPath( "foo", ContainerExtractorPath.explicitExtractors( Arrays.asList( BuiltinContainerExtractors.COLLECTION, BuiltinContainerExtractors.ITERABLE ) ), "bar", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.MAP_KEY ) ) ); } | public static Builder builder() { return new Builder(); } | PojoModelPath { public static Builder builder() { return new Builder(); } } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } |
@Test public void builder_chainedContainerExtractors_defaultExtractors() { assertThat( PojoModelPath.builder().property( "foo" ) .valueWithoutExtractors().valueWithDefaultExtractors() .toValuePath() ) .satisfies( isPath( "foo", ContainerExtractorPath.defaultExtractors() ) ); String errorMessage = "chain of multiple container extractors cannot include the default extractors"; assertThatThrownBy( () -> PojoModelPath.builder().property( "foo" ) .value( BuiltinContainerExtractors.COLLECTION ).valueWithDefaultExtractors() ) .isInstanceOf( SearchException.class ) .hasMessageContaining( errorMessage ); assertThatThrownBy( () -> PojoModelPath.builder().property( "foo" ) .valueWithDefaultExtractors().value( BuiltinContainerExtractors.COLLECTION ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( errorMessage ); } | public static Builder builder() { return new Builder(); } | PojoModelPath { public static Builder builder() { return new Builder(); } } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } | PojoModelPath { public static Builder builder() { return new Builder(); } PojoModelPath(); static Builder builder(); static PojoModelPathPropertyNode ofProperty(String propertyName); static PojoModelPathValueNode ofValue(String propertyName); static PojoModelPathValueNode ofValue(String propertyName, ContainerExtractorPath extractorPath); static PojoModelPathValueNode parse(String dotSeparatedPath); @Override String toString(); final String toPathString(); abstract PojoModelPath parent(); @Deprecated PojoModelPath getParent(); } |
@Test public void identifierBridge() { IdentifierBridgeToDocumentIdentifierContext toDocumentContext = new IdentifierBridgeToDocumentIdentifierContextImpl( mappingContext ); assertThat( toDocumentContext.extension( HibernateOrmExtension.get() ) ).isSameAs( mappingContext ); IdentifierBridgeFromDocumentIdentifierContext fromDocumentContext = new SessionBasedBridgeOperationContext( sessionContext ); assertThat( fromDocumentContext.extension( HibernateOrmExtension.get() ) ).isSameAs( sessionContext ); } | public static HibernateOrmExtension get() { return INSTANCE; } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); static HibernateOrmExtension get(); @Override Optional<HibernateOrmMappingContext> extendOptional(IdentifierBridgeToDocumentIdentifierContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(IdentifierBridgeFromDocumentIdentifierContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(RoutingBridgeRouteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(TypeBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(PropertyBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ValueBridgeToIndexedValueContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(ValueBridgeFromIndexedValueContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ToDocumentFieldValueConvertContext original,
BackendMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(FromDocumentFieldValueConvertContext original,
BackendSessionContext sessionContext); } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); static HibernateOrmExtension get(); @Override Optional<HibernateOrmMappingContext> extendOptional(IdentifierBridgeToDocumentIdentifierContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(IdentifierBridgeFromDocumentIdentifierContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(RoutingBridgeRouteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(TypeBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(PropertyBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ValueBridgeToIndexedValueContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(ValueBridgeFromIndexedValueContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ToDocumentFieldValueConvertContext original,
BackendMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(FromDocumentFieldValueConvertContext original,
BackendSessionContext sessionContext); } |
@Test public void split_transitive() { MyException1 exception1 = new MyException1(); MyException2 exception2 = new MyException2(); IOException exception3 = new IOException(); assertThatThrownBy( () -> { try ( Closer<IOException> closer1 = new Closer<>(); Closer<MyException1> closer2 = closer1.split(); Closer<MyException2> closer3 = closer2.split() ) { closer2.push( ignored -> { throw exception1; }, new Object() ); closer3.push( ignored -> { throw exception2; }, new Object() ); closer1.push( ignored -> { throw exception3; }, new Object() ); } } ) .isSameAs( exception1 ) .hasSuppressedException( exception2 ) .hasSuppressedException( exception3 ); } | public <E2 extends Exception> Closer<E2> split() { return new Closer<>( state ); } | Closer extends AbstractCloser<Closer<E>, E> implements AutoCloseable { public <E2 extends Exception> Closer<E2> split() { return new Closer<>( state ); } } | Closer extends AbstractCloser<Closer<E>, E> implements AutoCloseable { public <E2 extends Exception> Closer<E2> split() { return new Closer<>( state ); } Closer(); private Closer(CloseableState state); } | Closer extends AbstractCloser<Closer<E>, E> implements AutoCloseable { public <E2 extends Exception> Closer<E2> split() { return new Closer<>( state ); } Closer(); private Closer(CloseableState state); Closer<E2> split(); @Override void close(); } | Closer extends AbstractCloser<Closer<E>, E> implements AutoCloseable { public <E2 extends Exception> Closer<E2> split() { return new Closer<>( state ); } Closer(); private Closer(CloseableState state); Closer<E2> split(); @Override void close(); } |
@Test public void routingBridge() { RoutingBridgeRouteContext context = new SessionBasedBridgeOperationContext( sessionContext ); assertThat( context.extension( HibernateOrmExtension.get() ) ).isSameAs( sessionContext ); } | public static HibernateOrmExtension get() { return INSTANCE; } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); static HibernateOrmExtension get(); @Override Optional<HibernateOrmMappingContext> extendOptional(IdentifierBridgeToDocumentIdentifierContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(IdentifierBridgeFromDocumentIdentifierContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(RoutingBridgeRouteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(TypeBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(PropertyBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ValueBridgeToIndexedValueContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(ValueBridgeFromIndexedValueContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ToDocumentFieldValueConvertContext original,
BackendMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(FromDocumentFieldValueConvertContext original,
BackendSessionContext sessionContext); } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); static HibernateOrmExtension get(); @Override Optional<HibernateOrmMappingContext> extendOptional(IdentifierBridgeToDocumentIdentifierContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(IdentifierBridgeFromDocumentIdentifierContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(RoutingBridgeRouteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(TypeBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(PropertyBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ValueBridgeToIndexedValueContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(ValueBridgeFromIndexedValueContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ToDocumentFieldValueConvertContext original,
BackendMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(FromDocumentFieldValueConvertContext original,
BackendSessionContext sessionContext); } |
@Test @SuppressWarnings("deprecation") public void routingKeyBridge() { org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContext context = new SessionBasedBridgeOperationContext( sessionContext ); assertThat( context.extension( HibernateOrmExtension.get() ) ).isSameAs( sessionContext ); } | public static HibernateOrmExtension get() { return INSTANCE; } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); static HibernateOrmExtension get(); @Override Optional<HibernateOrmMappingContext> extendOptional(IdentifierBridgeToDocumentIdentifierContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(IdentifierBridgeFromDocumentIdentifierContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(RoutingBridgeRouteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(TypeBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(PropertyBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ValueBridgeToIndexedValueContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(ValueBridgeFromIndexedValueContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ToDocumentFieldValueConvertContext original,
BackendMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(FromDocumentFieldValueConvertContext original,
BackendSessionContext sessionContext); } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); static HibernateOrmExtension get(); @Override Optional<HibernateOrmMappingContext> extendOptional(IdentifierBridgeToDocumentIdentifierContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(IdentifierBridgeFromDocumentIdentifierContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(RoutingBridgeRouteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(TypeBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(PropertyBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ValueBridgeToIndexedValueContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(ValueBridgeFromIndexedValueContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ToDocumentFieldValueConvertContext original,
BackendMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(FromDocumentFieldValueConvertContext original,
BackendSessionContext sessionContext); } |
@Test public void typeBridge() { TypeBridgeWriteContext context = new SessionBasedBridgeOperationContext( sessionContext ); assertThat( context.extension( HibernateOrmExtension.get() ) ).isSameAs( sessionContext ); } | public static HibernateOrmExtension get() { return INSTANCE; } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); static HibernateOrmExtension get(); @Override Optional<HibernateOrmMappingContext> extendOptional(IdentifierBridgeToDocumentIdentifierContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(IdentifierBridgeFromDocumentIdentifierContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(RoutingBridgeRouteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(TypeBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(PropertyBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ValueBridgeToIndexedValueContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(ValueBridgeFromIndexedValueContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ToDocumentFieldValueConvertContext original,
BackendMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(FromDocumentFieldValueConvertContext original,
BackendSessionContext sessionContext); } | HibernateOrmExtension implements IdentifierBridgeToDocumentIdentifierContextExtension<HibernateOrmMappingContext>,
IdentifierBridgeFromDocumentIdentifierContextExtension<HibernateOrmSessionContext>,
RoutingBridgeRouteContextExtension<HibernateOrmSessionContext>,
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContextExtension<HibernateOrmSessionContext>,
TypeBridgeWriteContextExtension<HibernateOrmSessionContext>,
PropertyBridgeWriteContextExtension<HibernateOrmSessionContext>,
ValueBridgeToIndexedValueContextExtension<HibernateOrmMappingContext>,
ValueBridgeFromIndexedValueContextExtension<HibernateOrmSessionContext>,
ToDocumentFieldValueConvertContextExtension<HibernateOrmMappingContext>,
FromDocumentFieldValueConvertContextExtension<HibernateOrmSessionContext> { public static HibernateOrmExtension get() { return INSTANCE; } private HibernateOrmExtension(); static HibernateOrmExtension get(); @Override Optional<HibernateOrmMappingContext> extendOptional(IdentifierBridgeToDocumentIdentifierContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(IdentifierBridgeFromDocumentIdentifierContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(RoutingBridgeRouteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(
org.hibernate.search.mapper.pojo.bridge.runtime.RoutingKeyBridgeToRoutingKeyContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(TypeBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmSessionContext> extendOptional(PropertyBridgeWriteContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ValueBridgeToIndexedValueContext original,
BridgeMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(ValueBridgeFromIndexedValueContext original,
BridgeSessionContext sessionContext); @Override Optional<HibernateOrmMappingContext> extendOptional(ToDocumentFieldValueConvertContext original,
BackendMappingContext mappingContext); @Override Optional<HibernateOrmSessionContext> extendOptional(FromDocumentFieldValueConvertContext original,
BackendSessionContext sessionContext); } |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.