@Test public void create_TimeRangeIsNotNull() { ProfileWiFi profile01 = mock(ProfileWiFi.class); when(profile01.getProfileType()).thenReturn(ProfileType.WIFI); List<PacketInfo> packetlist1 = new ArrayList<PacketInfo>(); TimeRange timeRange = mock(TimeRange.class); when(timeRange.getBeginTime()).thenReturn((double) date.getTime() - 3000.0); when(timeRange.getEndTime()).thenReturn((double) date.getTime() + 1000.0); List<RrcStateRange> staterangelist = new ArrayList<RrcStateRange>(); RrcStateRange rrc01 = mock(RrcStateRange.class); RrcStateRange rrc02 = mock(RrcStateRange.class); RrcStateRange rrc03 = mock(RrcStateRange.class); when(rrc01.getBeginTime()).thenReturn((double) date.getTime() - 3000.0); when(rrc01.getEndTime()).thenReturn((double) date.getTime() - 2000.0); when(rrc02.getBeginTime()).thenReturn((double) date.getTime() - 1000.0); when(rrc02.getEndTime()).thenReturn((double) date.getTime()); when(rrc03.getBeginTime()).thenReturn((double) date.getTime() + 1000.0); when(rrc03.getEndTime()).thenReturn((double) date.getTime() + 2000.0); when(profilefactory.energy3G(any(double.class), any(double.class), any(RRCState.class), any(Profile3G.class))) .thenReturn(2.0); when(rrc01.getState()).thenReturn(RRCState.TAIL_FACH); when(rrc02.getState()).thenReturn(RRCState.TAIL_FACH); when(rrc03.getState()).thenReturn(RRCState.TAIL_FACH); staterangelist.add(rrc01); staterangelist.add(rrc02); staterangelist.add(rrc03); when(staterange.create(any(ArrayList.class), any(Profile.class), any(double.class))).thenReturn(staterangelist); AbstractRrcStateMachine rrcStateMachinewifi = machineFactoryimpl.create(packetlist1, profile01, packetDuration, traceDuration, 0.0, timeRange); assertEquals(0.0, rrcStateMachinewifi.getJoulesPerKilobyte(), 0.0); }
@Override public AbstractRrcStateMachine create(List<PacketInfo> packetlist, Profile profile, double packetDuration, double traceDuration, double totalBytes, TimeRange timerange) { List<RrcStateRange> staterangelist = staterange.create(packetlist, profile, traceDuration); if(timerange != null){ staterangelist = this.getRRCStatesForTheTimeRange(staterangelist, timerange.getBeginTime(), timerange.getEndTime()); } AbstractRrcStateMachine data = null; if(profile.getProfileType() == ProfileType.T3G){ data = run3GRRcStatistics(staterangelist, (Profile3G)profile, totalBytes, packetDuration, traceDuration); }else if(profile.getProfileType() == ProfileType.LTE){ data = runLTERRcStatistics(staterangelist, (ProfileLTE)profile, packetlist, totalBytes, packetDuration, traceDuration); }else if(profile.getProfileType() == ProfileType.WIFI){ data = runWiFiRRcStatistics(staterangelist, (ProfileWiFi)profile, totalBytes, packetDuration, traceDuration); } if(data != null){ data.setStaterangelist(staterangelist); } return data; }
RrcStateMachineFactoryImpl implements IRrcStateMachineFactory { @Override public AbstractRrcStateMachine create(List<PacketInfo> packetlist, Profile profile, double packetDuration, double traceDuration, double totalBytes, TimeRange timerange) { List<RrcStateRange> staterangelist = staterange.create(packetlist, profile, traceDuration); if(timerange != null){ staterangelist = this.getRRCStatesForTheTimeRange(staterangelist, timerange.getBeginTime(), timerange.getEndTime()); } AbstractRrcStateMachine data = null; if(profile.getProfileType() == ProfileType.T3G){ data = run3GRRcStatistics(staterangelist, (Profile3G)profile, totalBytes, packetDuration, traceDuration); }else if(profile.getProfileType() == ProfileType.LTE){ data = runLTERRcStatistics(staterangelist, (ProfileLTE)profile, packetlist, totalBytes, packetDuration, traceDuration); }else if(profile.getProfileType() == ProfileType.WIFI){ data = runWiFiRRcStatistics(staterangelist, (ProfileWiFi)profile, totalBytes, packetDuration, traceDuration); } if(data != null){ data.setStaterangelist(staterangelist); } return data; } }
RrcStateMachineFactoryImpl implements IRrcStateMachineFactory { @Override public AbstractRrcStateMachine create(List<PacketInfo> packetlist, Profile profile, double packetDuration, double traceDuration, double totalBytes, TimeRange timerange) { List<RrcStateRange> staterangelist = staterange.create(packetlist, profile, traceDuration); if(timerange != null){ staterangelist = this.getRRCStatesForTheTimeRange(staterangelist, timerange.getBeginTime(), timerange.getEndTime()); } AbstractRrcStateMachine data = null; if(profile.getProfileType() == ProfileType.T3G){ data = run3GRRcStatistics(staterangelist, (Profile3G)profile, totalBytes, packetDuration, traceDuration); }else if(profile.getProfileType() == ProfileType.LTE){ data = runLTERRcStatistics(staterangelist, (ProfileLTE)profile, packetlist, totalBytes, packetDuration, traceDuration); }else if(profile.getProfileType() == ProfileType.WIFI){ data = runWiFiRRcStatistics(staterangelist, (ProfileWiFi)profile, totalBytes, packetDuration, traceDuration); } if(data != null){ data.setStaterangelist(staterangelist); } return data; }  }
RrcStateMachineFactoryImpl implements IRrcStateMachineFactory { @Override public AbstractRrcStateMachine create(List<PacketInfo> packetlist, Profile profile, double packetDuration, double traceDuration, double totalBytes, TimeRange timerange) { List<RrcStateRange> staterangelist = staterange.create(packetlist, profile, traceDuration); if(timerange != null){ staterangelist = this.getRRCStatesForTheTimeRange(staterangelist, timerange.getBeginTime(), timerange.getEndTime()); } AbstractRrcStateMachine data = null; if(profile.getProfileType() == ProfileType.T3G){ data = run3GRRcStatistics(staterangelist, (Profile3G)profile, totalBytes, packetDuration, traceDuration); }else if(profile.getProfileType() == ProfileType.LTE){ data = runLTERRcStatistics(staterangelist, (ProfileLTE)profile, packetlist, totalBytes, packetDuration, traceDuration); }else if(profile.getProfileType() == ProfileType.WIFI){ data = runWiFiRRcStatistics(staterangelist, (ProfileWiFi)profile, totalBytes, packetDuration, traceDuration); } if(data != null){ data.setStaterangelist(staterangelist); } return data; }  @Override AbstractRrcStateMachine create(List<PacketInfo> packetlist,
			Profile profile, double packetDuration, double traceDuration, double totalBytes,
			TimeRange timerange); }
RrcStateMachineFactoryImpl implements IRrcStateMachineFactory { @Override public AbstractRrcStateMachine create(List<PacketInfo> packetlist, Profile profile, double packetDuration, double traceDuration, double totalBytes, TimeRange timerange) { List<RrcStateRange> staterangelist = staterange.create(packetlist, profile, traceDuration); if(timerange != null){ staterangelist = this.getRRCStatesForTheTimeRange(staterangelist, timerange.getBeginTime(), timerange.getEndTime()); } AbstractRrcStateMachine data = null; if(profile.getProfileType() == ProfileType.T3G){ data = run3GRRcStatistics(staterangelist, (Profile3G)profile, totalBytes, packetDuration, traceDuration); }else if(profile.getProfileType() == ProfileType.LTE){ data = runLTERRcStatistics(staterangelist, (ProfileLTE)profile, packetlist, totalBytes, packetDuration, traceDuration); }else if(profile.getProfileType() == ProfileType.WIFI){ data = runWiFiRRcStatistics(staterangelist, (ProfileWiFi)profile, totalBytes, packetDuration, traceDuration); } if(data != null){ data.setStaterangelist(staterangelist); } return data; }  @Override AbstractRrcStateMachine create(List<PacketInfo> packetlist,
			Profile profile, double packetDuration, double traceDuration, double totalBytes,
			TimeRange timerange);  }