### Question:
Key implements Serializable { static Key newInstance(String templateId, String nameType, String nameValue) { return new Key(null,templateId,nameType,nameValue); } private  Key(); private  Key(ResourceId id, String templateId, String nameClass, String nameValue); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test public void testNewInstance() { Key k1=Key.newInstance(RESOURCE_ID); assertThat(k1,notNullValue()); assertThat(k1.templateId(),equalTo(TEMPLATE_ID)); assertThat(k1.nameType(),equalTo(String.class.getName())); assertThat(k1.nameValue(),notNullValue()); assertThat(k1.resourceId(),equalTo(RESOURCE_ID)); }
@Test public void testNewInstance$parts() { Key k1=Key.newInstance(RESOURCE_ID); Key k2=Key.newInstance(k1.templateId(),k1.nameType(),k1.nameValue()); assertThat(k2,notNullValue()); assertThat(k2.templateId(),equalTo(k1.templateId())); assertThat(k2.nameType(),equalTo(k1.nameType())); assertThat(k2.nameValue(),equalTo(k1.nameValue())); assertThat(k2.resourceId(),equalTo(k1.resourceId())); }
@Test public void testNewInstance$null() { Key key=Key.newInstance(null); assertThat(key,nullValue()); }
@Test public void testEquals$sameInstance() { Key key=Key.newInstance(RESOURCE_ID); assertThat(key,equalTo(key)); }
@Test public void testEquals$differentInstance$sameResourceId() { Key k1=Key.newInstance(RESOURCE_ID); Key k2=Key.newInstance(RESOURCE_ID); assertThat(k1,equalTo(k2)); }
@Test public void testEquals$differentType() { Key k1=Key.newInstance(RESOURCE_ID); assertThat((Object)k1,not(equalTo((Object)"random"))); }