### Question:
DeclareFieldAnalysis extends ASTAnalysisAdaptor { @Override public void analyzeType(InjectionNode injectionNode, ASTType astType, AnalysisContext context) { if (astType.isAnnotated(DeclareField.class)) { if (!injectionNode.containsAspect(ASTInjectionAspect.class)) { injectionNode.addAspect(ASTInjectionAspect.class, new ASTInjectionAspect()); } injectionNode.getAspect(ASTInjectionAspect.class).setAssignmentType(ASTInjectionAspect.InjectionAssignmentType.FIELD); } }  @Override void analyzeType(InjectionNode injectionNode, ASTType astType, AnalysisContext context);  }### Answer:
@Test public void testLocalAssignmentType() { InjectionNode declareFieldInjectionNode = injectionPointFactory.buildInjectionNode(DeclareFieldTarget.class, analysisContext); declareFieldAnalysis.analyzeType(declareFieldInjectionNode, declareFieldInjectionNode.getASTType(), analysisContext); assertTrue(declareFieldInjectionNode.containsAspect(ASTInjectionAspect.class)); assertEquals(ASTInjectionAspect.InjectionAssignmentType.FIELD, declareFieldInjectionNode.getAspect(ASTInjectionAspect.class).getAssignmentType()); }
@Test public void testFieldAssignmentType() { InjectionNode nonDeclareFieldInjectionNode = injectionPointFactory.buildInjectionNode(NonDeclareFieldTarget.class, analysisContext); declareFieldAnalysis.analyzeType(nonDeclareFieldInjectionNode, nonDeclareFieldInjectionNode.getASTType(), analysisContext); nonDeclareFieldInjectionNode.addAspect(new ASTInjectionAspect()); assertEquals(ASTInjectionAspect.InjectionAssignmentType.LOCAL, nonDeclareFieldInjectionNode.getAspect(ASTInjectionAspect.class).getAssignmentType()); declareFieldAnalysis.analyzeType(nonDeclareFieldInjectionNode, nonDeclareFieldInjectionNode.getASTType(), analysisContext); assertTrue(nonDeclareFieldInjectionNode.containsAspect(ASTInjectionAspect.class)); assertEquals(ASTInjectionAspect.InjectionAssignmentType.LOCAL, nonDeclareFieldInjectionNode.getAspect(ASTInjectionAspect.class).getAssignmentType()); }