code: public static void defineDesignDocument(CouchbaseMock mock, String designName, String contents, String bucketName) throws IOException {
          URL url = getDesignURL(mock, designName, bucketName);
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          setAuthHeaders(mock, bucketName, conn);
  
          conn.setRequestMethod("PUT");
          conn.setRequestProperty("Content-Type", "application/json");
          conn.setDoOutput(true);
          conn.setDoInput(true);
  
          OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream());
          osw.write(contents);
          osw.flush();
          osw.close();
  
          try {
              conn.getInputStream().close();
          } catch (IOException ex) {
              InputStream es = conn.getErrorStream();
              if (es != null) {
                  System.err.printf("Problem creating view: %s%n", ReaderUtils.fromStream(es));
              } else {
                  System.err.printf("Error stream is null!\n");
              }
              throw ex;
          }
      }
docs: Utility method to define a view