@Test public void failsToIterateOverEmptyComponents() throws Exception { AlternativeProvider sut= new AlternativeProvider( Lists.<MediaType>newArrayList(), Lists.<CharacterEncoding>newArrayList(), Lists.<Language>newArrayList()); try { sut.next(); fail("Should fail to iterate over the end"); } catch (NoSuchElementException e) { assertThat(e.getMessage(),equalTo("No more alternatives available")); } }
@Override public ImmutableAlternative next() { if(!hasNext()) { throw new NoSuchElementException("No more alternatives available"); } final ImmutableAlternative alternative= ImmutableAlternative.create(currentQuality(),currentVariant()); discardVariant(); return alternative; }
AlternativeProvider implements Iterator<Alternative> { @Override public ImmutableAlternative next() { if(!hasNext()) { throw new NoSuchElementException("No more alternatives available"); } final ImmutableAlternative alternative= ImmutableAlternative.create(currentQuality(),currentVariant()); discardVariant(); return alternative; } }
AlternativeProvider implements Iterator<Alternative> { @Override public ImmutableAlternative next() { if(!hasNext()) { throw new NoSuchElementException("No more alternatives available"); } final ImmutableAlternative alternative= ImmutableAlternative.create(currentQuality(),currentVariant()); discardVariant(); return alternative; } AlternativeProvider(List<MediaType> mediaTypes, List<CharacterEncoding> characterEncodings, List<Language> languages); }
AlternativeProvider implements Iterator<Alternative> { @Override public ImmutableAlternative next() { if(!hasNext()) { throw new NoSuchElementException("No more alternatives available"); } final ImmutableAlternative alternative= ImmutableAlternative.create(currentQuality(),currentVariant()); discardVariant(); return alternative; } AlternativeProvider(List<MediaType> mediaTypes, List<CharacterEncoding> characterEncodings, List<Language> languages); @Override boolean hasNext(); @Override ImmutableAlternative next(); @Override void remove(); }
AlternativeProvider implements Iterator<Alternative> { @Override public ImmutableAlternative next() { if(!hasNext()) { throw new NoSuchElementException("No more alternatives available"); } final ImmutableAlternative alternative= ImmutableAlternative.create(currentQuality(),currentVariant()); discardVariant(); return alternative; } AlternativeProvider(List<MediaType> mediaTypes, List<CharacterEncoding> characterEncodings, List<Language> languages); @Override boolean hasNext(); @Override ImmutableAlternative next(); @Override void remove();  }