### Question:
TemplateOptions extends RunScriptOptions implements Cloneable { public TemplateOptions authorizePublicKey(String publicKey) { checkArgument(checkNotNull(publicKey, "publicKey").startsWith("ssh-rsa"), "key should start with ssh-rsa"); this.publicKey = publicKey; return this; }  @Override TemplateOptions clone(); void copyTo(TemplateOptions to); boolean equals(Object o); @Override int hashCode(); @Override ToStringHelper string(); int[] getInboundPorts(); Statement getRunScript(); Set<String> getTags(); Set<String> getNodeNames(); Set<String> getGroups(); String getPrivateKey(); String getPublicKey(); Set<String> getNetworks(); boolean shouldBlockUntilRunning(); T as(Class<T> clazz); TemplateOptions runScript(String script); TemplateOptions runScript(Statement script); TemplateOptions installPrivateKey(String privateKey); TemplateOptions dontAuthorizePublicKey(); TemplateOptions authorizePublicKey(String publicKey); TemplateOptions tags(Iterable<String> tags); TemplateOptions nodeNames(Iterable<String> nodeNames); TemplateOptions securityGroups(Iterable<String> securityGroups); TemplateOptions securityGroups(String... securityGroups); TemplateOptions networks(Iterable<String> networks); TemplateOptions networks(String... networks); TemplateOptions inboundPorts(int... ports); TemplateOptions blockUntilRunning(boolean blockUntilRunning); TemplateOptions userMetadata(Map<String, String> userMetadata); TemplateOptions userMetadata(String key, String value); Map<String, String> getUserMetadata(); @Override TemplateOptions blockOnPort(int port, int seconds); @Override TemplateOptions nameTask(String name); @Override TemplateOptions runAsRoot(boolean runAsRoot); @Override TemplateOptions wrapInInitScript(boolean wrapInInitScript); @Override TemplateOptions blockOnComplete(boolean blockOnComplete); @Override TemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials); @Override TemplateOptions overrideLoginPassword(String password); @Override TemplateOptions overrideLoginPrivateKey(String privateKey); @Override TemplateOptions overrideLoginUser(String loginUser); @Override TemplateOptions overrideAuthenticateSudo(boolean authenticateSudo); static final TemplateOptions NONE; }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class) public void testauthorizePublicKeyBadFormat() { TemplateOptions options = new TemplateOptions(); options.authorizePublicKey("whompy"); }
@Test public void testauthorizePublicKey() throws IOException { TemplateOptions options = new TemplateOptions(); options.authorizePublicKey("ssh-rsa"); assertEquals(options.toString(), "{publicKeyPresent=true}"); assertEquals(options.getPublicKey(), "ssh-rsa"); }
@Test(expectedExceptions = NullPointerException.class) public void testauthorizePublicKeyNPE() { authorizePublicKey((String) null); }