### Question:
Credentials implements Writable { public void mergeAll(Credentials other) { addAll(other, false); } Credentials();  Credentials(Credentials credentials); byte[] getSecretKey(Text alias); Token<? extends TokenIdentifier> getToken(Text alias); void addToken(Text alias, Token<? extends TokenIdentifier> t); Collection<Token<? extends TokenIdentifier>> getAllTokens(); int numberOfTokens(); int numberOfSecretKeys(); void addSecretKey(Text alias, byte[] key); static Credentials readTokenStorageFile(Path filename, Configuration conf); static Credentials readTokenStorageFile(File filename, Configuration conf); void readTokenStorageStream(DataInputStream in); void writeTokenStorageToStream(DataOutputStream os); void writeTokenStorageFile(Path filename, 
                                    Configuration conf); @Override void write(DataOutput out); @Override void readFields(DataInput in); void addAll(Credentials other); void mergeAll(Credentials other);  }### Answer:
@Test public void mergeAll() { Credentials creds = new Credentials(); creds.addToken(service[0], token[0]); creds.addToken(service[1], token[1]); creds.addSecretKey(secret[0], secret[0].getBytes()); creds.addSecretKey(secret[1], secret[1].getBytes()); Credentials credsToAdd = new Credentials(); credsToAdd.addToken(service[0], token[3]); credsToAdd.addToken(service[2], token[2]); credsToAdd.addSecretKey(secret[0], secret[3].getBytes()); credsToAdd.addSecretKey(secret[2], secret[2].getBytes()); creds.mergeAll(credsToAdd); assertEquals(3, creds.numberOfTokens()); assertEquals(3, creds.numberOfSecretKeys()); assertEquals(token[0], creds.getToken(service[0])); assertEquals(secret[0], new Text(creds.getSecretKey(secret[0]))); assertEquals(token[1], creds.getToken(service[1])); assertEquals(secret[1], new Text(creds.getSecretKey(secret[1]))); assertEquals(token[2], creds.getToken(service[2])); assertEquals(secret[2], new Text(creds.getSecretKey(secret[2]))); }