@Test public void resolveResourceExisting() { Resource expected = mock(Resource.class); this.locations = singletonList(new ClassPathResource("/META-INF/resources/webjars/", getClass())); String file = "foo/2.3/foo.txt"; given(this.chain.resolveResource(this.exchange, file, this.locations)).willReturn(Mono.just(expected)); Resource actual = this.resolver .resolveResource(this.exchange, file, this.locations, this.chain) .block(TIMEOUT); assertEquals(expected, actual); verify(this.chain, times(1)).resolveResource(this.exchange, file, this.locations); }
@Test public void resolveResourceWebJar() { this.locations = singletonList(new ClassPathResource("/META-INF/resources/webjars/", getClass())); String file = "underscorejs/underscore.js"; given(this.chain.resolveResource(this.exchange, file, this.locations)).willReturn(Mono.empty()); Resource expected = mock(Resource.class); String expectedPath = "underscorejs/1.8.3/underscore.js"; given(this.chain.resolveResource(this.exchange, expectedPath, this.locations)) .willReturn(Mono.just(expected)); Resource actual = this.resolver .resolveResource(this.exchange, file, this.locations, this.chain) .block(TIMEOUT); assertEquals(expected, actual); verify(this.chain, times(1)).resolveResource(this.exchange, file, this.locations); }
@Test public void resolveResourceNotFound() { String file = "something/something.js"; given(this.chain.resolveResource(this.exchange, file, this.locations)).willReturn(Mono.empty()); Resource actual = this.resolver .resolveResource(this.exchange, file, this.locations, this.chain) .block(TIMEOUT); assertNull(actual); verify(this.chain, times(1)).resolveResource(this.exchange, file, this.locations); verify(this.chain, never()).resolveResource(this.exchange, null, this.locations); }