### Question:
ReplicationService extends Service implements PolicyReplicationsCompletedListener { public void setReplicators(Replicator[] replicators) { if (mReplicatorsInitialised) { throw new IllegalStateException("Replicators already set"); } if (replicators != null && replicators.length > 0) { if (mReplicationPolicyManager == null) { mReplicationPolicyManager = new ReplicationPolicyManager(); } mReplicationPolicyManager.addReplicators(replicators); mReplicationPolicyManager.setReplicationsCompletedListener(this); synchronized (mCommandQueue) { mReplicatorsInitialised = true; for (Message msg : mCommandQueue) { mServiceHandler.sendMessage(msg); } mCommandQueue.clear(); } } else { throw new IllegalArgumentException( "No replications setup. Please pass Replicators to setReplicators" + "(Replicator[])"); } }  @Override void onCreate(); void setReplicators(Replicator[] replicators); @Override int onStartCommand(Intent intent, int flags, int startId); @Override IBinder onBind(Intent intent); @Override boolean onUnbind(Intent intent); @Override void onRebind(Intent intent); void setReplicationPolicyManager(ReplicationPolicyManager replicationPolicyManager); @Override void allReplicationsCompleted(); @Override void replicationCompleted(int id); @Override void replicationErrored(int id); void addListener(PolicyReplicationsCompletedListener listener); void removeListener(PolicyReplicationsCompletedListener listener); void setOperationStartedListener(OperationStartedListener listener); static final String EXTRA_INTENT; static final String EXTRA_COMMAND; static final int COMMAND_NONE; static final int COMMAND_START_REPLICATION; static final int COMMAND_STOP_REPLICATION; }### Answer:
@Test public void testSetReplicatorsNull() { PeriodicReplicationService service = new TestReplicationService(mMockContext); try { service.setReplicators(null); fail("IllegalArgumentException should have been thrown"); } catch (IllegalArgumentException e) { } }
@Test public void testSetReplicatorsEmpty() { PeriodicReplicationService service = new TestReplicationService(mMockContext); try { service.setReplicators(new Replicator[]{}); fail("IllegalArgumentException should have been thrown"); } catch (IllegalArgumentException e) { } }
@Test public void testSetReplicatorsMultipleInvocations() { PeriodicReplicationService service = new TestReplicationService(mMockContext); service.setReplicators(mMockReplicators); try { service.setReplicators(mMockReplicators); fail("IllegalStateException should have been thrown"); } catch (IllegalStateException e) { } }