Question: I have a ui-select field

```
{
  key: 'data_id',
  type: 'ui-select',
  templateOptions: {
    required: true,
    label: 'Select label',
    options: [],
    valueProp: 'id',
    labelProp: 'name'
  },
  controller: function($scope, DataService) {
    DataService.getSelectData().then(function(response) {
      $scope.to.options = response.data;
    });
  }
}

```

How can I access that inner controller in my unit tests and check that data loading for the select field actually works ?

**UPDATE:**
An example of a test could be as such:

```
var initializePageController = function() {
  return $controller('PageCtrl', {
    '$state': $state,
    '$stateParams': $stateParams
  });
};

var initializeSelectController = function(selectElement) {
  return $controller(selectElement.controller, {
    '$scope': $scope
  });
};

```

Then test case looks like:

```
it('should be able to get list of data....', function() {
   $scope.to = {};
   var vm = initializePageController();

   $httpBackend.expectGET(/\/api\/v1\/data...../).respond([
     {id: 1, name: 'Data 1'},
     {id: 2, name: 'Data 2'}
   ]);

   initializeSelectController(vm.fields[1]);
   $httpBackend.flush();

   expect($scope.to.options.length).to.equal(2);
});

```

Answer: 
You have a wildcard in the type parameter of your `handler` variable. The compiler doesn't know what the exact type of this type parameter is, only that it's either `Monitor` or a subclass.

The `call` method takes a `T`, which is matched on the wildcard. But there is no guarantee that the wildcard type is a `ContainsMonitor`. It could be a `Monitor`, or it could be `MonitorSubtypeThatDoesntExistYet`. Because the compiler doesn't know the actual type, it cannot allow you to pass anything except `null`, because with any non-`null` argument, it can't guarantee type safety.

You can get around this by removing the wildcard, and replacing that concept with a type parameter on the `Monitor` class.

```
class Monitor<T extends Monitor<T>>
{
    WebScoutCallable<T> handler;

    public void setCallable(WebScoutCallable<T> callable) {
         this.handler = callable;
    }
}

```

The interface `WebScoutCallable` changes a little in response:

```
interface WebScoutCallable<T extends Monitor<T>> {
    public void call(T caller);
}

```

The subclass feeds its own name as the type argument when extending `Monitor`.

```
class ContainsMonitor extends Monitor<ContainsMonitor> {
     public void handleDocument() {
          handler.call(this);
     }
}

```

Now, `T` will be a known type, and `ContainsMonitor` defines it to be itself, so it's now legal for it to pass itself to `call`.
`? extends Monitor` means: a specific subclass of Monitor, but we don't know which one. So it may be a `ContainsMonitor` or not and `handler` may or may not be able to accept a `ContainsMonitor`. The compiler can't decide and shows an error.

One way to solve your problem is to use specific types, for example:

```
class Monitor<T extends Monitor<T>> {
  WebScoutCallable<T> handler;

  public setCallable(WebScoutCallable<T> callable) {
    this.handler = callable;
  }
}

class ContainsMonitor extends Monitor<ContainsMonitor> {
  public void handleDocument() {
    handler.call(this);
  }
}

```