Q:

Test that method is called with proper parameters all across the software

I've just ran into a problem recently when a method in my service was called with wrong parameters. This caused some kind of outage, so I'm thinking about how to prevent that in the future.
So assuming that I have the following method:
public boolean doSomething(String param1, String param2);

I want to verify that each time this method is called (no matter where in my service), the param1 value is specific (e.g. only String1, String2 and String3 would be a valid parameter value for that.
Is there any technology/library/tool for that to verify this for instance in a unit test?
Update: as the accepted answer suggests, this is something that should not be covered through unit tests since unit tests are for behavioural testing. What would prevent the wrong call in the future is using Preconditions or just simple parameter check.

A:

When possible you should leverage compile-time checks rather than deferring the tests to runtime. If there are only three legal values then perhaps param1 should be an enum rather than a String.
Unit tests are for verifying that a method behaves in a certain way. They treat the method like a black box and poke it from the outside. They don't help if you're concerned with how it is called. There you're inside the method and want to verify that the outside world is well-behaved. The way to do that is with run-time precondition checks at the start of the method.
public boolean doSomething(String param1, String param2) {
    if (!Objects.equals(param1, "String1") &&
        !Objects.equals(param1, "String2") &&
        !Objects.equals(param1, "String3"))
    {
        throw IllegalArgumentException("param1 must be String1, 2, or 3");
    }

    ...
}

Guava's Preconditions class can be helpful.
public boolean doSomething(String param1, String param2) {
    Preconditions.checkArgument(
        Objects.equals(param1, "String1") ||
        Objects.equals(param1, "String2") ||
        Objects.equals(param1, "String3"),
        "param1 must be String1, 2, or 3"
    );

    ...
}

