### Question:
MtasApiServiceImpl implements MtasApiService { @Override public ResponseEntity<Mta> getMta(String spaceGuid, String mtaId) { List<DeployedMta> mtas = deployedMtaDetector.detectDeployedMtasByName(mtaId, getCloudFoundryClient(spaceGuid)); if (mtas.isEmpty()) { throw new NotFoundException(Messages.MTA_NOT_FOUND, mtaId); } if (mtas.size() != 1) { throw new ConflictException(Messages.MTA_SEARCH_NOT_UNIQUE_BY_NAME, mtaId); } return ResponseEntity.ok() .body(getMta(mtas.get(0))); }  @Override ResponseEntity<List<Mta>> getMtas(String spaceGuid); @Override ResponseEntity<Mta> getMta(String spaceGuid, String mtaId); @Override ResponseEntity<List<Mta>> getMtas(String spaceGuid, String namespace, String name);  }### Answer:
@Test void testGetMta() { Mta mtaToGet = mtas.get(1); Mockito.when(deployedMtaDetector.detectDeployedMtasByName(mtaToGet.getMetadata() .getId(), client)) .thenReturn(List.of(getDeployedMta(mtaToGet))); ResponseEntity<Mta> response = testedClass.getMta(SPACE_GUID, mtaToGet.getMetadata() .getId()); assertEquals(HttpStatus.OK, response.getStatusCode()); Mta responseMta = response.getBody(); assertEquals(mtaToGet, responseMta); }
@Test void testGetMtaNotFound() { Assertions.assertThrows(NotFoundException.class, () -> testedClass.getMta(SPACE_GUID, "not_a_real_mta")); }
@Test void testGetMtaNotUniqueByName() { Mockito.when(deployedMtaDetector.detectDeployedMtasByName("name_thats_not_unique", client)) .thenReturn(getDeployedMtas(mtas)); Assertions.assertThrows(ConflictException.class, () -> testedClass.getMta(SPACE_GUID, "name_thats_not_unique")); }