EntanglingClass { @VisibleForTesting MethodSpec createDetangleMethod() { return MethodSpec.methodBuilder("detangle") .addModifiers(PUBLIC) .addStatement("quantum.Quantum.getTangle(id).deleteObservers()") .build(); } EntanglingClass(String classPackage, String className, String targetClass, String fieldName, String connectionId);   }
@Test public void detangleMethodShouldHaveCorrectName() { MethodSpec detangle = entanglingClass.createDetangleMethod(); assertThat(detangle.name, is("detangle")); }
@Test public void detangleMethodShouldBePublic() { MethodSpec detangle = entanglingClass.createDetangleMethod(); assertThat(detangle.modifiers, hasItem(Modifier.PUBLIC)); }
@Test public void detangleMethodShouldHaveOnlyOneModifier() { MethodSpec detangle = entanglingClass.createDetangleMethod(); assertThat(detangle.modifiers, hasSize(1)); }
@Test public void detangleMethodShouldHaveNoParameters() { MethodSpec detangle = entanglingClass.createDetangleMethod(); assertThat(detangle.parameters, is(Collections.<ParameterSpec>emptyList())); }
@Test public void detangleMethodCodeShouldDeleteObservers() { MethodSpec method = entanglingClass.createDetangleMethod(); assertThat(method.code.toString(), is("quantum.Quantum.getTangle(id).deleteObservers();\n")); }