Question: I need to remove all occurring patterns except 1, but I haven't been able to get this working in a Bash script.
I tried 

```
sed -e 's/ /\\ /g' -e 's/\\ / /1' 

```

and 

```
sed ':a;s/\([^ ]* .*[^\\]\) \(.*\)/\1\\ \2/;ta'

```

but neither do have the desired effect unfortunately. 

Is someone able to help me out?
Thank you in advance!

Answer: 
At the end its easy to explain. If you just look into the javadocs of the annotations you will see the differences:

@Mock: (`org.mockito.Mock`)

> 
> Mark a field as a mock.
> 
> 
> 

> 
> * Allows shorthand mock creation.
> * Minimizes repetitive mock creation code.
> * Makes the test class more readable.
> * Makes the verification error easier to read because the field name is used to identify the mock.
> 
> 
> 

@MockBean: (`org.springframework.boot.test.mock.mockito.MockBean`)

> 
> Annotation that can be used to add mocks to a Spring ApplicationContext. Can be used as a class level annotation or on fields in either `@Configuration` classes, or test classes that are `@RunWith` the SpringRunner.
> 
> 
> 

> 
> Mocks can be registered by type or by bean name. Any existing single bean of the same type defined in the context will be replaced by the mock, if no existing bean is defined a new one will be added.
> 
> 
> 

> 
> When `@MockBean` is used on a field, as well as being registered in the application context, the mock will also be injected into the field.
> 
> 
> 

Mockito.mock()

> 
> Its just the representation of a `@Mock`.
> 
> 
>
Mocktio.mock() :-

1. Will create a mock object of either class or interface. We can use
this mock to stub the return values and verify if they are called.
2. We must use the `when(..)` and `thenReturn(..)` methods for mock objects
whose class methods will be invoked during test case execution.

`@Mock` :-

1. This is shorthand for `mock()` method so it is preferable and often
used.
2. Both `mock()` and `@Mock` are functionally equivalent.
3. Easier to identify the problem in mock failure as name of the field appears in the error message.

To enable the Mockito annotation during test execution we need to call the `MockitoAnnotations.initMocks(this)` method but this method is deprecated instead we can call - `MockitoAnnotations.openMocks(this)`. In order to avoid the side effects it is advised to call this method before test case executions.

Another way to enable the Mockito annotations is by annotating the test class with `@RunWith` by specifying the MockitoJUnitRunner that does this task and also other useful things.

`@MockBean` :-
It is used to add the mock objects into spring application context.
This mock will replace the existing bean of same type in application
context. If no bean is available, then new bean will be added. This
is useful in integration test case.

When we write a test case that doesn't need any dependencies from the Spring Boot container, the classic/plain Mockito is used and it is fast and favors the isolation of the tested component.

If our test case needs to rely on the Spring Boot container and want to add or mock one of the container beans then `@MockBean` is used.