Example usage for org.apache.commons.collections4 Closure Closure

List of usage examples for org.apache.commons.collections4 Closure Closure

Introduction

In this page you can find the example usage for org.apache.commons.collections4 Closure Closure.

Prototype

Closure

Source Link

Usage

From source file:com.vrem.wifianalyzer.wifi.channelgraph.ChannelGraphNavigationTest.java

@Test
public void testMapping() throws Exception {
    assertEquals(WiFiChannelsGHZ5.SETS.size(), ChannelGraphNavigation.ids.size());
    IterableUtils.forEach(WiFiChannelsGHZ5.SETS, new Closure<Pair<WiFiChannel, WiFiChannel>>() {
        @Override//from ww  w . ja va2 s .com
        public void execute(Pair<WiFiChannel, WiFiChannel> set) {
            assertNotNull(ChannelGraphNavigation.ids.get(set));
        }
    });
}

From source file:com.vrem.wifianalyzer.wifi.channelgraph.ChannelGraphNavigationTest.java

@Test
public void testConstructor() throws Exception {
    IterableUtils.forEach(ChannelGraphNavigation.ids.values(), new Closure<Integer>() {
        @Override//w  ww. j  a v a2 s  . c om
        public void execute(Integer input) {
            verify(layout).findViewById(input);
        }
    });
    IterableUtils.forEach(views.values(), new Closure<View>() {
        @Override
        public void execute(View view) {
            verify(view).setOnClickListener(any(ChannelGraphNavigation.SetOnClickListener.class));
        }
    });
}

From source file:com.vrem.wifianalyzer.wifi.graphutils.SeriesCacheTest.java

@Test
public void testRemoveExpectedAllLeft() throws Exception {
    // setup//from w  ww.  j ava  2  s  .com
    List<WiFiDetail> expected = withData();
    // execute
    List<BaseSeries<DataPoint>> actual = fixture.remove(new ArrayList<WiFiDetail>());
    // validate
    assertTrue(actual.isEmpty());
    IterableUtils.forEach(expected, new Closure<WiFiDetail>() {
        @Override
        public void execute(WiFiDetail wiFiDetail) {
            assertTrue(fixture.contains(wiFiDetail));
        }
    });
}

From source file:com.vrem.wifianalyzer.wifi.band.WiFiChannelCountryGHZ5Test.java

@Test
public void testChannelsOther() throws Exception {
    final int expectedSize = CHANNELS_SET1.size() + CHANNELS_SET2.size() + CHANNELS_SET3.size();
    List<String> countries = Arrays.asList("US", "RU", "XYZ");
    IterableUtils.forEach(countries, new Closure<String>() {
        @Override//from   w w w .ja  v a  2 s  . com
        public void execute(String country) {
            Set<Integer> actual = fixture.findChannels(country);
            assertEquals(expectedSize, actual.size());
            assertTrue(actual.containsAll(CHANNELS_SET1));
            assertTrue(actual.containsAll(CHANNELS_SET2));
            assertTrue(actual.containsAll(CHANNELS_SET3));
        }
    });
}

From source file:com.vrem.wifianalyzer.wifi.model.WiFiDataTest.java

private void withVendorNames() {
    IterableUtils.forEach(wiFiDetails, new Closure<WiFiDetail>() {
        @Override/*from  ww w .j a  va2  s  .c  o m*/
        public void execute(WiFiDetail wiFiDetail) {
            when(vendorService.findVendorName(wiFiDetail.getBSSID()))
                    .thenReturn(VENDOR_NAME + wiFiDetail.getBSSID());
        }
    });
}

From source file:com.vrem.wifianalyzer.wifi.graphutils.SeriesCacheTest.java

@Test
public void testRemoveExpectNoneLeft() throws Exception {
    // setup//  ww w.  jav a2s .com
    List<WiFiDetail> expected = withData();
    // execute
    List<BaseSeries<DataPoint>> actual = fixture.remove(expected);
    // validate
    assertEquals(expected.size(), actual.size());
    IterableUtils.forEach(expected, new Closure<WiFiDetail>() {
        @Override
        public void execute(WiFiDetail wiFiDetail) {
            assertFalse(fixture.contains(wiFiDetail));
        }
    });
}

From source file:com.vrem.wifianalyzer.wifi.timegraph.DataManagerTest.java

@Test
public void testAdjustDataAppendsData() throws Exception {
    // setup/*w w w.ja v  a2 s  .  co m*/
    Set<WiFiDetail> wiFiDetails = new TreeSet<>();
    List<WiFiDetail> difference = makeWiFiDetails();
    int xValue = fixture.getXValue();
    final Integer scanCount = fixture.getScanCount();
    final DataPoint dataPoint = new DataPoint(xValue, DataManager.MIN_Y + DataManager.MIN_Y_OFFSET);
    when(graphViewWrapper.differenceSeries(wiFiDetails)).thenReturn(difference);
    // execute
    fixture.adjustData(graphViewWrapper, wiFiDetails);
    // validate
    IterableUtils.forEach(difference, new Closure<WiFiDetail>() {
        @Override
        public void execute(WiFiDetail wiFiDetail) {
            verify(graphViewWrapper).appendToSeries(argThat(equalTo(wiFiDetail)),
                    argThat(new DataPointEquals(dataPoint)), argThat(equalTo(scanCount)),
                    argThat(equalTo(wiFiDetail.getWiFiAdditional().getWiFiConnection().isConnected())));
            verify(timeGraphCache).add(wiFiDetail);
        }
    });
    verify(timeGraphCache).clear();
}

From source file:com.vrem.wifianalyzer.wifi.channelgraph.ChannelGraphNavigationTest.java

@Test
public void testUpdateWithGHZ5AndUS() throws Exception {
    // setup//from  w w w . j  a  v  a  2 s. c  o  m
    final int colorSelected = ContextCompat.getColor(mainActivity, R.color.connected);
    final int colorNotSelected = ContextCompat.getColor(mainActivity, R.color.connected_background);
    final Pair<WiFiChannel, WiFiChannel> selectedKey = WiFiBand.GHZ5.getWiFiChannels().getWiFiChannelPairs()
            .get(0);
    when(configuration.getWiFiChannelPair()).thenReturn(selectedKey);
    when(settings.getCountryCode()).thenReturn(Locale.US.getCountry());
    when(settings.getWiFiBand()).thenReturn(WiFiBand.GHZ5);
    when(settings.getSortBy()).thenReturn(SortBy.CHANNEL);
    // execute
    fixture.update(WiFiData.EMPTY);
    // validate
    verify(layout).setVisibility(View.VISIBLE);
    IterableUtils.forEach(views.keySet(), new Closure<Pair<WiFiChannel, WiFiChannel>>() {
        @Override
        public void execute(Pair<WiFiChannel, WiFiChannel> key) {
            Button button = (Button) views.get(key);
            verify(button).setVisibility(View.VISIBLE);
            verify(button).setBackgroundColor(selectedKey.equals(key) ? colorSelected : colorNotSelected);
            verify(button).setSelected(selectedKey.equals(key));
        }
    });
    IterableUtils.forEach(ChannelGraphNavigation.ids.values(), new Closure<Integer>() {
        @Override
        public void execute(Integer id) {
            verify(layout, times(2)).findViewById(id);
        }
    });
    verify(settings).getCountryCode();
    verify(settings, times(2)).getWiFiBand();
    verify(settings).getSortBy();
    verify(configuration).getWiFiChannelPair();
}

From source file:com.vrem.wifianalyzer.wifi.graphutils.SeriesCacheTest.java

@Test
public void testRemoveNonExistingOne() throws Exception {
    // setup//from  w  ww. ja  va2s . c om
    List<WiFiDetail> expected = withData();
    List<WiFiDetail> toRemove = Collections.singletonList(makeWiFiDetail("SSID-999"));
    // execute
    List<BaseSeries<DataPoint>> actual = fixture.remove(toRemove);
    // validate
    assertTrue(actual.isEmpty());
    IterableUtils.forEach(expected, new Closure<WiFiDetail>() {
        @Override
        public void execute(WiFiDetail wiFiDetail) {
            assertTrue(fixture.contains(wiFiDetail));
        }
    });
}

From source file:com.vrem.util.EnumUtilsTest.java

private void validate(Collection<TestObject> expected, final Collection<TestObject> actual) {
    assertEquals(expected.size(), actual.size());
    IterableUtils.forEach(expected, new Closure<TestObject>() {
        @Override//from   w  ww  . jav a 2  s.c o m
        public void execute(TestObject input) {
            assertTrue(actual.contains(input));
        }
    });
}