/** * Returns the class in which this mutation is located * * @return class in which mutation is located */ public MethodName getMethod() { return this.id.getLocation().getMethodName(); }
private static Predicate<MutationDetails> isInStaticInitializer() { return a -> a.getId().getLocation().getMethodName().equals(CLINIT); }
private Function<MutationDetails, Location> mutationToLocation() { return a -> a.getId().getLocation(); }
private Predicate<MutationDetails> inEqualsMethod() { return a -> { final Location loc = a.getId().getLocation(); return loc.getMethodDesc().equals("(Ljava/lang/Object;)Z") && loc.getMethodName().equals(MethodName.fromString("equals")); }; }
@Override public boolean matches(MutationDetails value) { return value.getId().getLocation().getMethodName().name().equals(name); } };
public static MutationDetails makeMutation(final ClassName clazz) { return new MutationDetails(new MutationIdentifier(Location.location(clazz, new MethodName("aMethod"), "()V"), 1, "mutatorId"), "foo.java", "A mutation", 0, 0); }
private static Generator<MutationDetailsBuilder, MutationDetails> seed() { return b -> { final MutationDetails md = new MutationDetails(b._Id(), b._Filename(), b._Description(), b._LineNumber(), b._Block(), b._IsInFinallyBlock(), b._Poison()); md.addTestsInOrder(b._TestsInOrder()); return md; }; }
public static Function<MethodTree, Predicate<MutationDetails>> matchMutationsInMethod() { return method -> { final Location methodLocation = method.asLocation(); return a -> methodLocation.equals(a.getId().getLocation()); }; } }
public Location asLocation() { return Location.location(this.owner,MethodName.fromString(this.rawNode.name), this.rawNode.desc); }
/** * Returns the class in which this mutation is located * * @return class in which mutation is located */ public ClassName getClassName() { return this.location.getClassName(); }
/** * Returns the name of the mutator that created this mutation * * @return the mutator name */ public String getMutator() { return this.id.getMutator(); }
private Collection<MutationDetails> someMutations() { return aMutationDetail().build(2); }
/** * Zero based index to first affected ASM instruction * @return */ public int getInstructionIndex() { return getFirstIndex() - 1; }
/** * Returns true if this mutation has a matching identifier * * @param id * the MutationIdentifier to match * @return true if the MutationIdentifier matches otherwise false */ public Boolean matchesId(final MutationIdentifier id) { return this.id.matches(id); }
/** * Returns the class in which this mutation is located * * @return class in which mutation is located */ public ClassName getClassName() { return this.id.getClassName(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + ((this.id == null) ? 0 : this.id.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + this.block; result = (prime * result) + ((this.location == null) ? 0 : this.location.hashCode()); return result; }
/** * Indicates if this mutation might poison state within the jvm (e.g affect * the values of static variable) * * @return true if the mutation might poison the jvm otherwise false */ public boolean mayPoisonJVM() { return this.poison.mayPoison(); }
private void assertOnlyClinitMethodsMarked(Collection<MutationDetails> actual) { for (final MutationDetails each : actual ) { if (each.isInStaticInitializer()) { if (!each.getId().getLocation().getMethodName().name().equals("<clinit>")) { fail("Expected no mutants to be marked as for static initialization but " + each + " was"); } } } }