EvictionListBuilder { public EvictionList create() { if (this.controller.getEvictionAlgorithm().isLIFO()) { return new LIFOList(this.controller); } else { if (evictionScanAsync) { return new LRUListWithAsyncSorting(this.controller); } else { return new LRUListWithSyncSorting(this.controller); } } } EvictionListBuilder(EvictionController evictionController); EvictionList create();  }
@Test public void createsLIFOListWhenAlgorithmIsLifo() { EvictionAlgorithm lifoAlgorithm = EvictionAlgorithm.LIFO_ENTRY; when(controller.getEvictionAlgorithm()).thenReturn(lifoAlgorithm); assertThat(builder.create()).isInstanceOf(LIFOList.class); }
@Test public void createsAsyncLruByDefault() { assertThat(builder.create()).isInstanceOf(LRUListWithAsyncSorting.class); }
@Test public void createsAsyncLruWhenSystemConfiguredToUseIt() { System.setProperty(EVICTION_PROPERTY_NAME, "true"); builder = new EvictionListBuilder(controller); assertThat(builder.create()).isInstanceOf(LRUListWithAsyncSorting.class); }
@Test public void createdSyncLruWhenSystemConfiguredToUseIt() { System.setProperty(EVICTION_PROPERTY_NAME, "false"); builder = new EvictionListBuilder(controller); assertThat(builder.create()).isInstanceOf(LRUListWithSyncSorting.class); }