github.com/cloudwego/kitex@v0.9.0/internal/mocks/thrift/fast/test.go (about)

     1  /*
     2   * Copyright 2022 CloudWeGo Authors
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  // Code generated by thriftgo (0.2.1). DO NOT EDIT.
    18  
    19  package fast
    20  
    21  import (
    22  	"context"
    23  	"fmt"
    24  	"strings"
    25  
    26  	"github.com/apache/thrift/lib/go/thrift"
    27  )
    28  
    29  type MockReq struct {
    30  	Msg     string            `thrift:"Msg,1" json:"Msg"`
    31  	StrMap  map[string]string `thrift:"strMap,2" json:"strMap"`
    32  	StrList []string          `thrift:"strList,3" json:"strList"`
    33  }
    34  
    35  func NewMockReq() *MockReq {
    36  	return &MockReq{}
    37  }
    38  
    39  func (p *MockReq) GetMsg() (v string) {
    40  	return p.Msg
    41  }
    42  
    43  func (p *MockReq) GetStrMap() (v map[string]string) {
    44  	return p.StrMap
    45  }
    46  
    47  func (p *MockReq) GetStrList() (v []string) {
    48  	return p.StrList
    49  }
    50  func (p *MockReq) SetMsg(val string) {
    51  	p.Msg = val
    52  }
    53  func (p *MockReq) SetStrMap(val map[string]string) {
    54  	p.StrMap = val
    55  }
    56  func (p *MockReq) SetStrList(val []string) {
    57  	p.StrList = val
    58  }
    59  
    60  var fieldIDToName_MockReq = map[int16]string{
    61  	1: "Msg",
    62  	2: "strMap",
    63  	3: "strList",
    64  }
    65  
    66  func (p *MockReq) Read(iprot thrift.TProtocol) (err error) {
    67  
    68  	var fieldTypeId thrift.TType
    69  	var fieldId int16
    70  
    71  	if _, err = iprot.ReadStructBegin(); err != nil {
    72  		goto ReadStructBeginError
    73  	}
    74  
    75  	for {
    76  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
    77  		if err != nil {
    78  			goto ReadFieldBeginError
    79  		}
    80  		if fieldTypeId == thrift.STOP {
    81  			break
    82  		}
    83  
    84  		switch fieldId {
    85  		case 1:
    86  			if fieldTypeId == thrift.STRING {
    87  				if err = p.ReadField1(iprot); err != nil {
    88  					goto ReadFieldError
    89  				}
    90  			} else {
    91  				if err = iprot.Skip(fieldTypeId); err != nil {
    92  					goto SkipFieldError
    93  				}
    94  			}
    95  		case 2:
    96  			if fieldTypeId == thrift.MAP {
    97  				if err = p.ReadField2(iprot); err != nil {
    98  					goto ReadFieldError
    99  				}
   100  			} else {
   101  				if err = iprot.Skip(fieldTypeId); err != nil {
   102  					goto SkipFieldError
   103  				}
   104  			}
   105  		case 3:
   106  			if fieldTypeId == thrift.LIST {
   107  				if err = p.ReadField3(iprot); err != nil {
   108  					goto ReadFieldError
   109  				}
   110  			} else {
   111  				if err = iprot.Skip(fieldTypeId); err != nil {
   112  					goto SkipFieldError
   113  				}
   114  			}
   115  		default:
   116  			if err = iprot.Skip(fieldTypeId); err != nil {
   117  				goto SkipFieldError
   118  			}
   119  		}
   120  
   121  		if err = iprot.ReadFieldEnd(); err != nil {
   122  			goto ReadFieldEndError
   123  		}
   124  	}
   125  	if err = iprot.ReadStructEnd(); err != nil {
   126  		goto ReadStructEndError
   127  	}
   128  
   129  	return nil
   130  ReadStructBeginError:
   131  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   132  ReadFieldBeginError:
   133  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   134  ReadFieldError:
   135  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MockReq[fieldId]), err)
   136  SkipFieldError:
   137  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   138  
   139  ReadFieldEndError:
   140  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   141  ReadStructEndError:
   142  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   143  }
   144  
   145  func (p *MockReq) ReadField1(iprot thrift.TProtocol) error {
   146  	if v, err := iprot.ReadString(); err != nil {
   147  		return err
   148  	} else {
   149  		p.Msg = v
   150  	}
   151  	return nil
   152  }
   153  
   154  func (p *MockReq) ReadField2(iprot thrift.TProtocol) error {
   155  	_, _, size, err := iprot.ReadMapBegin()
   156  	if err != nil {
   157  		return err
   158  	}
   159  	p.StrMap = make(map[string]string, size)
   160  	for i := 0; i < size; i++ {
   161  		var _key string
   162  		if v, err := iprot.ReadString(); err != nil {
   163  			return err
   164  		} else {
   165  			_key = v
   166  		}
   167  
   168  		var _val string
   169  		if v, err := iprot.ReadString(); err != nil {
   170  			return err
   171  		} else {
   172  			_val = v
   173  		}
   174  
   175  		p.StrMap[_key] = _val
   176  	}
   177  	if err := iprot.ReadMapEnd(); err != nil {
   178  		return err
   179  	}
   180  	return nil
   181  }
   182  
   183  func (p *MockReq) ReadField3(iprot thrift.TProtocol) error {
   184  	_, size, err := iprot.ReadListBegin()
   185  	if err != nil {
   186  		return err
   187  	}
   188  	p.StrList = make([]string, 0, size)
   189  	for i := 0; i < size; i++ {
   190  		var _elem string
   191  		if v, err := iprot.ReadString(); err != nil {
   192  			return err
   193  		} else {
   194  			_elem = v
   195  		}
   196  
   197  		p.StrList = append(p.StrList, _elem)
   198  	}
   199  	if err := iprot.ReadListEnd(); err != nil {
   200  		return err
   201  	}
   202  	return nil
   203  }
   204  
   205  func (p *MockReq) Write(oprot thrift.TProtocol) (err error) {
   206  	var fieldId int16
   207  	if err = oprot.WriteStructBegin("MockReq"); err != nil {
   208  		goto WriteStructBeginError
   209  	}
   210  	if p != nil {
   211  		if err = p.writeField1(oprot); err != nil {
   212  			fieldId = 1
   213  			goto WriteFieldError
   214  		}
   215  		if err = p.writeField2(oprot); err != nil {
   216  			fieldId = 2
   217  			goto WriteFieldError
   218  		}
   219  		if err = p.writeField3(oprot); err != nil {
   220  			fieldId = 3
   221  			goto WriteFieldError
   222  		}
   223  
   224  	}
   225  	if err = oprot.WriteFieldStop(); err != nil {
   226  		goto WriteFieldStopError
   227  	}
   228  	if err = oprot.WriteStructEnd(); err != nil {
   229  		goto WriteStructEndError
   230  	}
   231  	return nil
   232  WriteStructBeginError:
   233  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   234  WriteFieldError:
   235  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   236  WriteFieldStopError:
   237  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   238  WriteStructEndError:
   239  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   240  }
   241  
   242  func (p *MockReq) writeField1(oprot thrift.TProtocol) (err error) {
   243  	if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil {
   244  		goto WriteFieldBeginError
   245  	}
   246  	if err := oprot.WriteString(p.Msg); err != nil {
   247  		return err
   248  	}
   249  	if err = oprot.WriteFieldEnd(); err != nil {
   250  		goto WriteFieldEndError
   251  	}
   252  	return nil
   253  WriteFieldBeginError:
   254  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   255  WriteFieldEndError:
   256  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   257  }
   258  
   259  func (p *MockReq) writeField2(oprot thrift.TProtocol) (err error) {
   260  	if err = oprot.WriteFieldBegin("strMap", thrift.MAP, 2); err != nil {
   261  		goto WriteFieldBeginError
   262  	}
   263  	if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.StrMap)); err != nil {
   264  		return err
   265  	}
   266  	for k, v := range p.StrMap {
   267  
   268  		if err := oprot.WriteString(k); err != nil {
   269  			return err
   270  		}
   271  
   272  		if err := oprot.WriteString(v); err != nil {
   273  			return err
   274  		}
   275  	}
   276  	if err := oprot.WriteMapEnd(); err != nil {
   277  		return err
   278  	}
   279  	if err = oprot.WriteFieldEnd(); err != nil {
   280  		goto WriteFieldEndError
   281  	}
   282  	return nil
   283  WriteFieldBeginError:
   284  	return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
   285  WriteFieldEndError:
   286  	return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
   287  }
   288  
   289  func (p *MockReq) writeField3(oprot thrift.TProtocol) (err error) {
   290  	if err = oprot.WriteFieldBegin("strList", thrift.LIST, 3); err != nil {
   291  		goto WriteFieldBeginError
   292  	}
   293  	if err := oprot.WriteListBegin(thrift.STRING, len(p.StrList)); err != nil {
   294  		return err
   295  	}
   296  	for _, v := range p.StrList {
   297  		if err := oprot.WriteString(v); err != nil {
   298  			return err
   299  		}
   300  	}
   301  	if err := oprot.WriteListEnd(); err != nil {
   302  		return err
   303  	}
   304  	if err = oprot.WriteFieldEnd(); err != nil {
   305  		goto WriteFieldEndError
   306  	}
   307  	return nil
   308  WriteFieldBeginError:
   309  	return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
   310  WriteFieldEndError:
   311  	return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
   312  }
   313  
   314  func (p *MockReq) String() string {
   315  	if p == nil {
   316  		return "<nil>"
   317  	}
   318  	return fmt.Sprintf("MockReq(%+v)", *p)
   319  }
   320  
   321  func (p *MockReq) DeepEqual(ano *MockReq) bool {
   322  	if p == ano {
   323  		return true
   324  	} else if p == nil || ano == nil {
   325  		return false
   326  	}
   327  	if !p.Field1DeepEqual(ano.Msg) {
   328  		return false
   329  	}
   330  	if !p.Field2DeepEqual(ano.StrMap) {
   331  		return false
   332  	}
   333  	if !p.Field3DeepEqual(ano.StrList) {
   334  		return false
   335  	}
   336  	return true
   337  }
   338  
   339  func (p *MockReq) Field1DeepEqual(src string) bool {
   340  
   341  	if strings.Compare(p.Msg, src) != 0 {
   342  		return false
   343  	}
   344  	return true
   345  }
   346  func (p *MockReq) Field2DeepEqual(src map[string]string) bool {
   347  
   348  	if len(p.StrMap) != len(src) {
   349  		return false
   350  	}
   351  	for k, v := range p.StrMap {
   352  		_src := src[k]
   353  		if strings.Compare(v, _src) != 0 {
   354  			return false
   355  		}
   356  	}
   357  	return true
   358  }
   359  func (p *MockReq) Field3DeepEqual(src []string) bool {
   360  
   361  	if len(p.StrList) != len(src) {
   362  		return false
   363  	}
   364  	for i, v := range p.StrList {
   365  		_src := src[i]
   366  		if strings.Compare(v, _src) != 0 {
   367  			return false
   368  		}
   369  	}
   370  	return true
   371  }
   372  
   373  type Exception struct {
   374  	Code int32  `thrift:"code,1" json:"code"`
   375  	Msg  string `thrift:"msg,255" json:"msg"`
   376  }
   377  
   378  func NewException() *Exception {
   379  	return &Exception{}
   380  }
   381  
   382  func (p *Exception) GetCode() (v int32) {
   383  	return p.Code
   384  }
   385  
   386  func (p *Exception) GetMsg() (v string) {
   387  	return p.Msg
   388  }
   389  func (p *Exception) SetCode(val int32) {
   390  	p.Code = val
   391  }
   392  func (p *Exception) SetMsg(val string) {
   393  	p.Msg = val
   394  }
   395  
   396  var fieldIDToName_Exception = map[int16]string{
   397  	1:   "code",
   398  	255: "msg",
   399  }
   400  
   401  func (p *Exception) Read(iprot thrift.TProtocol) (err error) {
   402  
   403  	var fieldTypeId thrift.TType
   404  	var fieldId int16
   405  
   406  	if _, err = iprot.ReadStructBegin(); err != nil {
   407  		goto ReadStructBeginError
   408  	}
   409  
   410  	for {
   411  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
   412  		if err != nil {
   413  			goto ReadFieldBeginError
   414  		}
   415  		if fieldTypeId == thrift.STOP {
   416  			break
   417  		}
   418  
   419  		switch fieldId {
   420  		case 1:
   421  			if fieldTypeId == thrift.I32 {
   422  				if err = p.ReadField1(iprot); err != nil {
   423  					goto ReadFieldError
   424  				}
   425  			} else {
   426  				if err = iprot.Skip(fieldTypeId); err != nil {
   427  					goto SkipFieldError
   428  				}
   429  			}
   430  		case 255:
   431  			if fieldTypeId == thrift.STRING {
   432  				if err = p.ReadField255(iprot); err != nil {
   433  					goto ReadFieldError
   434  				}
   435  			} else {
   436  				if err = iprot.Skip(fieldTypeId); err != nil {
   437  					goto SkipFieldError
   438  				}
   439  			}
   440  		default:
   441  			if err = iprot.Skip(fieldTypeId); err != nil {
   442  				goto SkipFieldError
   443  			}
   444  		}
   445  
   446  		if err = iprot.ReadFieldEnd(); err != nil {
   447  			goto ReadFieldEndError
   448  		}
   449  	}
   450  	if err = iprot.ReadStructEnd(); err != nil {
   451  		goto ReadStructEndError
   452  	}
   453  
   454  	return nil
   455  ReadStructBeginError:
   456  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   457  ReadFieldBeginError:
   458  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   459  ReadFieldError:
   460  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Exception[fieldId]), err)
   461  SkipFieldError:
   462  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   463  
   464  ReadFieldEndError:
   465  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   466  ReadStructEndError:
   467  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   468  }
   469  
   470  func (p *Exception) ReadField1(iprot thrift.TProtocol) error {
   471  	if v, err := iprot.ReadI32(); err != nil {
   472  		return err
   473  	} else {
   474  		p.Code = v
   475  	}
   476  	return nil
   477  }
   478  
   479  func (p *Exception) ReadField255(iprot thrift.TProtocol) error {
   480  	if v, err := iprot.ReadString(); err != nil {
   481  		return err
   482  	} else {
   483  		p.Msg = v
   484  	}
   485  	return nil
   486  }
   487  
   488  func (p *Exception) Write(oprot thrift.TProtocol) (err error) {
   489  	var fieldId int16
   490  	if err = oprot.WriteStructBegin("Exception"); err != nil {
   491  		goto WriteStructBeginError
   492  	}
   493  	if p != nil {
   494  		if err = p.writeField1(oprot); err != nil {
   495  			fieldId = 1
   496  			goto WriteFieldError
   497  		}
   498  		if err = p.writeField255(oprot); err != nil {
   499  			fieldId = 255
   500  			goto WriteFieldError
   501  		}
   502  
   503  	}
   504  	if err = oprot.WriteFieldStop(); err != nil {
   505  		goto WriteFieldStopError
   506  	}
   507  	if err = oprot.WriteStructEnd(); err != nil {
   508  		goto WriteStructEndError
   509  	}
   510  	return nil
   511  WriteStructBeginError:
   512  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   513  WriteFieldError:
   514  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   515  WriteFieldStopError:
   516  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   517  WriteStructEndError:
   518  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   519  }
   520  
   521  func (p *Exception) writeField1(oprot thrift.TProtocol) (err error) {
   522  	if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil {
   523  		goto WriteFieldBeginError
   524  	}
   525  	if err := oprot.WriteI32(p.Code); err != nil {
   526  		return err
   527  	}
   528  	if err = oprot.WriteFieldEnd(); err != nil {
   529  		goto WriteFieldEndError
   530  	}
   531  	return nil
   532  WriteFieldBeginError:
   533  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   534  WriteFieldEndError:
   535  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   536  }
   537  
   538  func (p *Exception) writeField255(oprot thrift.TProtocol) (err error) {
   539  	if err = oprot.WriteFieldBegin("msg", thrift.STRING, 255); err != nil {
   540  		goto WriteFieldBeginError
   541  	}
   542  	if err := oprot.WriteString(p.Msg); err != nil {
   543  		return err
   544  	}
   545  	if err = oprot.WriteFieldEnd(); err != nil {
   546  		goto WriteFieldEndError
   547  	}
   548  	return nil
   549  WriteFieldBeginError:
   550  	return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err)
   551  WriteFieldEndError:
   552  	return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err)
   553  }
   554  
   555  func (p *Exception) String() string {
   556  	if p == nil {
   557  		return "<nil>"
   558  	}
   559  	return fmt.Sprintf("Exception(%+v)", *p)
   560  }
   561  func (p *Exception) Error() string {
   562  	return p.String()
   563  }
   564  
   565  func (p *Exception) DeepEqual(ano *Exception) bool {
   566  	if p == ano {
   567  		return true
   568  	} else if p == nil || ano == nil {
   569  		return false
   570  	}
   571  	if !p.Field1DeepEqual(ano.Code) {
   572  		return false
   573  	}
   574  	if !p.Field255DeepEqual(ano.Msg) {
   575  		return false
   576  	}
   577  	return true
   578  }
   579  
   580  func (p *Exception) Field1DeepEqual(src int32) bool {
   581  
   582  	if p.Code != src {
   583  		return false
   584  	}
   585  	return true
   586  }
   587  func (p *Exception) Field255DeepEqual(src string) bool {
   588  
   589  	if strings.Compare(p.Msg, src) != 0 {
   590  		return false
   591  	}
   592  	return true
   593  }
   594  
   595  type Mock interface {
   596  	Test(ctx context.Context, req *MockReq) (r string, err error)
   597  
   598  	ExceptionTest(ctx context.Context, req *MockReq) (r string, err error)
   599  }
   600  
   601  type MockClient struct {
   602  	c thrift.TClient
   603  }
   604  
   605  func NewMockClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *MockClient {
   606  	return &MockClient{
   607  		c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)),
   608  	}
   609  }
   610  
   611  func NewMockClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *MockClient {
   612  	return &MockClient{
   613  		c: thrift.NewTStandardClient(iprot, oprot),
   614  	}
   615  }
   616  
   617  func NewMockClient(c thrift.TClient) *MockClient {
   618  	return &MockClient{
   619  		c: c,
   620  	}
   621  }
   622  
   623  func (p *MockClient) Client_() thrift.TClient {
   624  	return p.c
   625  }
   626  
   627  func (p *MockClient) Test(ctx context.Context, req *MockReq) (r string, err error) {
   628  	var _args MockTestArgs
   629  	_args.Req = req
   630  	var _result MockTestResult
   631  	if err = p.Client_().Call(ctx, "Test", &_args, &_result); err != nil {
   632  		return
   633  	}
   634  	return _result.GetSuccess(), nil
   635  }
   636  func (p *MockClient) ExceptionTest(ctx context.Context, req *MockReq) (r string, err error) {
   637  	var _args MockExceptionTestArgs
   638  	_args.Req = req
   639  	var _result MockExceptionTestResult
   640  	if err = p.Client_().Call(ctx, "ExceptionTest", &_args, &_result); err != nil {
   641  		return
   642  	}
   643  	switch {
   644  	case _result.Err != nil:
   645  		return r, _result.Err
   646  	}
   647  	return _result.GetSuccess(), nil
   648  }
   649  
   650  type MockProcessor struct {
   651  	processorMap map[string]thrift.TProcessorFunction
   652  	handler      Mock
   653  }
   654  
   655  func (p *MockProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
   656  	p.processorMap[key] = processor
   657  }
   658  
   659  func (p *MockProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
   660  	processor, ok = p.processorMap[key]
   661  	return processor, ok
   662  }
   663  
   664  func (p *MockProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
   665  	return p.processorMap
   666  }
   667  
   668  func NewMockProcessor(handler Mock) *MockProcessor {
   669  	self := &MockProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
   670  	self.AddToProcessorMap("Test", &mockProcessorTest{handler: handler})
   671  	self.AddToProcessorMap("ExceptionTest", &mockProcessorExceptionTest{handler: handler})
   672  	return self
   673  }
   674  func (p *MockProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
   675  	name, _, seqId, err := iprot.ReadMessageBegin()
   676  	if err != nil {
   677  		return false, err
   678  	}
   679  	if processor, ok := p.GetProcessorFunction(name); ok {
   680  		return processor.Process(ctx, seqId, iprot, oprot)
   681  	}
   682  	iprot.Skip(thrift.STRUCT)
   683  	iprot.ReadMessageEnd()
   684  	x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
   685  	oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
   686  	x.Write(oprot)
   687  	oprot.WriteMessageEnd()
   688  	oprot.Flush(ctx)
   689  	return false, x
   690  }
   691  
   692  type mockProcessorTest struct {
   693  	handler Mock
   694  }
   695  
   696  func (p *mockProcessorTest) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
   697  	args := MockTestArgs{}
   698  	if err = args.Read(iprot); err != nil {
   699  		iprot.ReadMessageEnd()
   700  		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
   701  		oprot.WriteMessageBegin("Test", thrift.EXCEPTION, seqId)
   702  		x.Write(oprot)
   703  		oprot.WriteMessageEnd()
   704  		oprot.Flush(ctx)
   705  		return false, err
   706  	}
   707  
   708  	iprot.ReadMessageEnd()
   709  	var err2 error
   710  	result := MockTestResult{}
   711  	var retval string
   712  	if retval, err2 = p.handler.Test(ctx, args.Req); err2 != nil {
   713  		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Test: "+err2.Error())
   714  		oprot.WriteMessageBegin("Test", thrift.EXCEPTION, seqId)
   715  		x.Write(oprot)
   716  		oprot.WriteMessageEnd()
   717  		oprot.Flush(ctx)
   718  		return true, err2
   719  	} else {
   720  		result.Success = &retval
   721  	}
   722  	if err2 = oprot.WriteMessageBegin("Test", thrift.REPLY, seqId); err2 != nil {
   723  		err = err2
   724  	}
   725  	if err2 = result.Write(oprot); err == nil && err2 != nil {
   726  		err = err2
   727  	}
   728  	if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
   729  		err = err2
   730  	}
   731  	if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
   732  		err = err2
   733  	}
   734  	if err != nil {
   735  		return
   736  	}
   737  	return true, err
   738  }
   739  
   740  type mockProcessorExceptionTest struct {
   741  	handler Mock
   742  }
   743  
   744  func (p *mockProcessorExceptionTest) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
   745  	args := MockExceptionTestArgs{}
   746  	if err = args.Read(iprot); err != nil {
   747  		iprot.ReadMessageEnd()
   748  		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
   749  		oprot.WriteMessageBegin("ExceptionTest", thrift.EXCEPTION, seqId)
   750  		x.Write(oprot)
   751  		oprot.WriteMessageEnd()
   752  		oprot.Flush(ctx)
   753  		return false, err
   754  	}
   755  
   756  	iprot.ReadMessageEnd()
   757  	var err2 error
   758  	result := MockExceptionTestResult{}
   759  	var retval string
   760  	if retval, err2 = p.handler.ExceptionTest(ctx, args.Req); err2 != nil {
   761  		switch v := err2.(type) {
   762  		case *Exception:
   763  			result.Err = v
   764  		default:
   765  			x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ExceptionTest: "+err2.Error())
   766  			oprot.WriteMessageBegin("ExceptionTest", thrift.EXCEPTION, seqId)
   767  			x.Write(oprot)
   768  			oprot.WriteMessageEnd()
   769  			oprot.Flush(ctx)
   770  			return true, err2
   771  		}
   772  	} else {
   773  		result.Success = &retval
   774  	}
   775  	if err2 = oprot.WriteMessageBegin("ExceptionTest", thrift.REPLY, seqId); err2 != nil {
   776  		err = err2
   777  	}
   778  	if err2 = result.Write(oprot); err == nil && err2 != nil {
   779  		err = err2
   780  	}
   781  	if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
   782  		err = err2
   783  	}
   784  	if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
   785  		err = err2
   786  	}
   787  	if err != nil {
   788  		return
   789  	}
   790  	return true, err
   791  }
   792  
   793  type MockTestArgs struct {
   794  	Req *MockReq `thrift:"req,1" json:"req"`
   795  }
   796  
   797  func NewMockTestArgs() *MockTestArgs {
   798  	return &MockTestArgs{}
   799  }
   800  
   801  var MockTestArgs_Req_DEFAULT *MockReq
   802  
   803  func (p *MockTestArgs) GetReq() (v *MockReq) {
   804  	if !p.IsSetReq() {
   805  		return MockTestArgs_Req_DEFAULT
   806  	}
   807  	return p.Req
   808  }
   809  func (p *MockTestArgs) SetReq(val *MockReq) {
   810  	p.Req = val
   811  }
   812  
   813  var fieldIDToName_MockTestArgs = map[int16]string{
   814  	1: "req",
   815  }
   816  
   817  func (p *MockTestArgs) IsSetReq() bool {
   818  	return p.Req != nil
   819  }
   820  
   821  func (p *MockTestArgs) Read(iprot thrift.TProtocol) (err error) {
   822  
   823  	var fieldTypeId thrift.TType
   824  	var fieldId int16
   825  
   826  	if _, err = iprot.ReadStructBegin(); err != nil {
   827  		goto ReadStructBeginError
   828  	}
   829  
   830  	for {
   831  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
   832  		if err != nil {
   833  			goto ReadFieldBeginError
   834  		}
   835  		if fieldTypeId == thrift.STOP {
   836  			break
   837  		}
   838  
   839  		switch fieldId {
   840  		case 1:
   841  			if fieldTypeId == thrift.STRUCT {
   842  				if err = p.ReadField1(iprot); err != nil {
   843  					goto ReadFieldError
   844  				}
   845  			} else {
   846  				if err = iprot.Skip(fieldTypeId); err != nil {
   847  					goto SkipFieldError
   848  				}
   849  			}
   850  		default:
   851  			if err = iprot.Skip(fieldTypeId); err != nil {
   852  				goto SkipFieldError
   853  			}
   854  		}
   855  
   856  		if err = iprot.ReadFieldEnd(); err != nil {
   857  			goto ReadFieldEndError
   858  		}
   859  	}
   860  	if err = iprot.ReadStructEnd(); err != nil {
   861  		goto ReadStructEndError
   862  	}
   863  
   864  	return nil
   865  ReadStructBeginError:
   866  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   867  ReadFieldBeginError:
   868  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   869  ReadFieldError:
   870  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MockTestArgs[fieldId]), err)
   871  SkipFieldError:
   872  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   873  
   874  ReadFieldEndError:
   875  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   876  ReadStructEndError:
   877  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   878  }
   879  
   880  func (p *MockTestArgs) ReadField1(iprot thrift.TProtocol) error {
   881  	p.Req = NewMockReq()
   882  	if err := p.Req.Read(iprot); err != nil {
   883  		return err
   884  	}
   885  	return nil
   886  }
   887  
   888  func (p *MockTestArgs) Write(oprot thrift.TProtocol) (err error) {
   889  	var fieldId int16
   890  	if err = oprot.WriteStructBegin("Test_args"); err != nil {
   891  		goto WriteStructBeginError
   892  	}
   893  	if p != nil {
   894  		if err = p.writeField1(oprot); err != nil {
   895  			fieldId = 1
   896  			goto WriteFieldError
   897  		}
   898  
   899  	}
   900  	if err = oprot.WriteFieldStop(); err != nil {
   901  		goto WriteFieldStopError
   902  	}
   903  	if err = oprot.WriteStructEnd(); err != nil {
   904  		goto WriteStructEndError
   905  	}
   906  	return nil
   907  WriteStructBeginError:
   908  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   909  WriteFieldError:
   910  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   911  WriteFieldStopError:
   912  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   913  WriteStructEndError:
   914  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   915  }
   916  
   917  func (p *MockTestArgs) writeField1(oprot thrift.TProtocol) (err error) {
   918  	if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil {
   919  		goto WriteFieldBeginError
   920  	}
   921  	if err := p.Req.Write(oprot); err != nil {
   922  		return err
   923  	}
   924  	if err = oprot.WriteFieldEnd(); err != nil {
   925  		goto WriteFieldEndError
   926  	}
   927  	return nil
   928  WriteFieldBeginError:
   929  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   930  WriteFieldEndError:
   931  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   932  }
   933  
   934  func (p *MockTestArgs) String() string {
   935  	if p == nil {
   936  		return "<nil>"
   937  	}
   938  	return fmt.Sprintf("MockTestArgs(%+v)", *p)
   939  }
   940  
   941  func (p *MockTestArgs) DeepEqual(ano *MockTestArgs) bool {
   942  	if p == ano {
   943  		return true
   944  	} else if p == nil || ano == nil {
   945  		return false
   946  	}
   947  	if !p.Field1DeepEqual(ano.Req) {
   948  		return false
   949  	}
   950  	return true
   951  }
   952  
   953  func (p *MockTestArgs) Field1DeepEqual(src *MockReq) bool {
   954  
   955  	if !p.Req.DeepEqual(src) {
   956  		return false
   957  	}
   958  	return true
   959  }
   960  
   961  type MockTestResult struct {
   962  	Success *string `thrift:"success,0,optional" json:"success,omitempty"`
   963  }
   964  
   965  func NewMockTestResult() *MockTestResult {
   966  	return &MockTestResult{}
   967  }
   968  
   969  var MockTestResult_Success_DEFAULT string
   970  
   971  func (p *MockTestResult) GetSuccess() (v string) {
   972  	if !p.IsSetSuccess() {
   973  		return MockTestResult_Success_DEFAULT
   974  	}
   975  	return *p.Success
   976  }
   977  func (p *MockTestResult) SetSuccess(x interface{}) {
   978  	p.Success = x.(*string)
   979  }
   980  
   981  var fieldIDToName_MockTestResult = map[int16]string{
   982  	0: "success",
   983  }
   984  
   985  func (p *MockTestResult) IsSetSuccess() bool {
   986  	return p.Success != nil
   987  }
   988  
   989  func (p *MockTestResult) Read(iprot thrift.TProtocol) (err error) {
   990  
   991  	var fieldTypeId thrift.TType
   992  	var fieldId int16
   993  
   994  	if _, err = iprot.ReadStructBegin(); err != nil {
   995  		goto ReadStructBeginError
   996  	}
   997  
   998  	for {
   999  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
  1000  		if err != nil {
  1001  			goto ReadFieldBeginError
  1002  		}
  1003  		if fieldTypeId == thrift.STOP {
  1004  			break
  1005  		}
  1006  
  1007  		switch fieldId {
  1008  		case 0:
  1009  			if fieldTypeId == thrift.STRING {
  1010  				if err = p.ReadField0(iprot); err != nil {
  1011  					goto ReadFieldError
  1012  				}
  1013  			} else {
  1014  				if err = iprot.Skip(fieldTypeId); err != nil {
  1015  					goto SkipFieldError
  1016  				}
  1017  			}
  1018  		default:
  1019  			if err = iprot.Skip(fieldTypeId); err != nil {
  1020  				goto SkipFieldError
  1021  			}
  1022  		}
  1023  
  1024  		if err = iprot.ReadFieldEnd(); err != nil {
  1025  			goto ReadFieldEndError
  1026  		}
  1027  	}
  1028  	if err = iprot.ReadStructEnd(); err != nil {
  1029  		goto ReadStructEndError
  1030  	}
  1031  
  1032  	return nil
  1033  ReadStructBeginError:
  1034  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
  1035  ReadFieldBeginError:
  1036  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
  1037  ReadFieldError:
  1038  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MockTestResult[fieldId]), err)
  1039  SkipFieldError:
  1040  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
  1041  
  1042  ReadFieldEndError:
  1043  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
  1044  ReadStructEndError:
  1045  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
  1046  }
  1047  
  1048  func (p *MockTestResult) ReadField0(iprot thrift.TProtocol) error {
  1049  	if v, err := iprot.ReadString(); err != nil {
  1050  		return err
  1051  	} else {
  1052  		p.Success = &v
  1053  	}
  1054  	return nil
  1055  }
  1056  
  1057  func (p *MockTestResult) Write(oprot thrift.TProtocol) (err error) {
  1058  	var fieldId int16
  1059  	if err = oprot.WriteStructBegin("Test_result"); err != nil {
  1060  		goto WriteStructBeginError
  1061  	}
  1062  	if p != nil {
  1063  		if err = p.writeField0(oprot); err != nil {
  1064  			fieldId = 0
  1065  			goto WriteFieldError
  1066  		}
  1067  
  1068  	}
  1069  	if err = oprot.WriteFieldStop(); err != nil {
  1070  		goto WriteFieldStopError
  1071  	}
  1072  	if err = oprot.WriteStructEnd(); err != nil {
  1073  		goto WriteStructEndError
  1074  	}
  1075  	return nil
  1076  WriteStructBeginError:
  1077  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
  1078  WriteFieldError:
  1079  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
  1080  WriteFieldStopError:
  1081  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
  1082  WriteStructEndError:
  1083  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
  1084  }
  1085  
  1086  func (p *MockTestResult) writeField0(oprot thrift.TProtocol) (err error) {
  1087  	if p.IsSetSuccess() {
  1088  		if err = oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil {
  1089  			goto WriteFieldBeginError
  1090  		}
  1091  		if err := oprot.WriteString(*p.Success); err != nil {
  1092  			return err
  1093  		}
  1094  		if err = oprot.WriteFieldEnd(); err != nil {
  1095  			goto WriteFieldEndError
  1096  		}
  1097  	}
  1098  	return nil
  1099  WriteFieldBeginError:
  1100  	return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err)
  1101  WriteFieldEndError:
  1102  	return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err)
  1103  }
  1104  
  1105  func (p *MockTestResult) String() string {
  1106  	if p == nil {
  1107  		return "<nil>"
  1108  	}
  1109  	return fmt.Sprintf("MockTestResult(%+v)", *p)
  1110  }
  1111  
  1112  func (p *MockTestResult) DeepEqual(ano *MockTestResult) bool {
  1113  	if p == ano {
  1114  		return true
  1115  	} else if p == nil || ano == nil {
  1116  		return false
  1117  	}
  1118  	if !p.Field0DeepEqual(ano.Success) {
  1119  		return false
  1120  	}
  1121  	return true
  1122  }
  1123  
  1124  func (p *MockTestResult) Field0DeepEqual(src *string) bool {
  1125  
  1126  	if p.Success == src {
  1127  		return true
  1128  	} else if p.Success == nil || src == nil {
  1129  		return false
  1130  	}
  1131  	if strings.Compare(*p.Success, *src) != 0 {
  1132  		return false
  1133  	}
  1134  	return true
  1135  }
  1136  
  1137  type MockExceptionTestArgs struct {
  1138  	Req *MockReq `thrift:"req,1" json:"req"`
  1139  }
  1140  
  1141  func NewMockExceptionTestArgs() *MockExceptionTestArgs {
  1142  	return &MockExceptionTestArgs{}
  1143  }
  1144  
  1145  var MockExceptionTestArgs_Req_DEFAULT *MockReq
  1146  
  1147  func (p *MockExceptionTestArgs) GetReq() (v *MockReq) {
  1148  	if !p.IsSetReq() {
  1149  		return MockExceptionTestArgs_Req_DEFAULT
  1150  	}
  1151  	return p.Req
  1152  }
  1153  func (p *MockExceptionTestArgs) SetReq(val *MockReq) {
  1154  	p.Req = val
  1155  }
  1156  
  1157  var fieldIDToName_MockExceptionTestArgs = map[int16]string{
  1158  	1: "req",
  1159  }
  1160  
  1161  func (p *MockExceptionTestArgs) IsSetReq() bool {
  1162  	return p.Req != nil
  1163  }
  1164  
  1165  func (p *MockExceptionTestArgs) Read(iprot thrift.TProtocol) (err error) {
  1166  
  1167  	var fieldTypeId thrift.TType
  1168  	var fieldId int16
  1169  
  1170  	if _, err = iprot.ReadStructBegin(); err != nil {
  1171  		goto ReadStructBeginError
  1172  	}
  1173  
  1174  	for {
  1175  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
  1176  		if err != nil {
  1177  			goto ReadFieldBeginError
  1178  		}
  1179  		if fieldTypeId == thrift.STOP {
  1180  			break
  1181  		}
  1182  
  1183  		switch fieldId {
  1184  		case 1:
  1185  			if fieldTypeId == thrift.STRUCT {
  1186  				if err = p.ReadField1(iprot); err != nil {
  1187  					goto ReadFieldError
  1188  				}
  1189  			} else {
  1190  				if err = iprot.Skip(fieldTypeId); err != nil {
  1191  					goto SkipFieldError
  1192  				}
  1193  			}
  1194  		default:
  1195  			if err = iprot.Skip(fieldTypeId); err != nil {
  1196  				goto SkipFieldError
  1197  			}
  1198  		}
  1199  
  1200  		if err = iprot.ReadFieldEnd(); err != nil {
  1201  			goto ReadFieldEndError
  1202  		}
  1203  	}
  1204  	if err = iprot.ReadStructEnd(); err != nil {
  1205  		goto ReadStructEndError
  1206  	}
  1207  
  1208  	return nil
  1209  ReadStructBeginError:
  1210  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
  1211  ReadFieldBeginError:
  1212  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
  1213  ReadFieldError:
  1214  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MockExceptionTestArgs[fieldId]), err)
  1215  SkipFieldError:
  1216  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
  1217  
  1218  ReadFieldEndError:
  1219  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
  1220  ReadStructEndError:
  1221  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
  1222  }
  1223  
  1224  func (p *MockExceptionTestArgs) ReadField1(iprot thrift.TProtocol) error {
  1225  	p.Req = NewMockReq()
  1226  	if err := p.Req.Read(iprot); err != nil {
  1227  		return err
  1228  	}
  1229  	return nil
  1230  }
  1231  
  1232  func (p *MockExceptionTestArgs) Write(oprot thrift.TProtocol) (err error) {
  1233  	var fieldId int16
  1234  	if err = oprot.WriteStructBegin("ExceptionTest_args"); err != nil {
  1235  		goto WriteStructBeginError
  1236  	}
  1237  	if p != nil {
  1238  		if err = p.writeField1(oprot); err != nil {
  1239  			fieldId = 1
  1240  			goto WriteFieldError
  1241  		}
  1242  
  1243  	}
  1244  	if err = oprot.WriteFieldStop(); err != nil {
  1245  		goto WriteFieldStopError
  1246  	}
  1247  	if err = oprot.WriteStructEnd(); err != nil {
  1248  		goto WriteStructEndError
  1249  	}
  1250  	return nil
  1251  WriteStructBeginError:
  1252  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
  1253  WriteFieldError:
  1254  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
  1255  WriteFieldStopError:
  1256  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
  1257  WriteStructEndError:
  1258  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
  1259  }
  1260  
  1261  func (p *MockExceptionTestArgs) writeField1(oprot thrift.TProtocol) (err error) {
  1262  	if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil {
  1263  		goto WriteFieldBeginError
  1264  	}
  1265  	if err := p.Req.Write(oprot); err != nil {
  1266  		return err
  1267  	}
  1268  	if err = oprot.WriteFieldEnd(); err != nil {
  1269  		goto WriteFieldEndError
  1270  	}
  1271  	return nil
  1272  WriteFieldBeginError:
  1273  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
  1274  WriteFieldEndError:
  1275  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
  1276  }
  1277  
  1278  func (p *MockExceptionTestArgs) String() string {
  1279  	if p == nil {
  1280  		return "<nil>"
  1281  	}
  1282  	return fmt.Sprintf("MockExceptionTestArgs(%+v)", *p)
  1283  }
  1284  
  1285  func (p *MockExceptionTestArgs) DeepEqual(ano *MockExceptionTestArgs) bool {
  1286  	if p == ano {
  1287  		return true
  1288  	} else if p == nil || ano == nil {
  1289  		return false
  1290  	}
  1291  	if !p.Field1DeepEqual(ano.Req) {
  1292  		return false
  1293  	}
  1294  	return true
  1295  }
  1296  
  1297  func (p *MockExceptionTestArgs) Field1DeepEqual(src *MockReq) bool {
  1298  
  1299  	if !p.Req.DeepEqual(src) {
  1300  		return false
  1301  	}
  1302  	return true
  1303  }
  1304  
  1305  type MockExceptionTestResult struct {
  1306  	Success *string    `thrift:"success,0,optional" json:"success,omitempty"`
  1307  	Err     *Exception `thrift:"err,1,optional" json:"err,omitempty"`
  1308  }
  1309  
  1310  func NewMockExceptionTestResult() *MockExceptionTestResult {
  1311  	return &MockExceptionTestResult{}
  1312  }
  1313  
  1314  var MockExceptionTestResult_Success_DEFAULT string
  1315  
  1316  func (p *MockExceptionTestResult) GetSuccess() (v string) {
  1317  	if !p.IsSetSuccess() {
  1318  		return MockExceptionTestResult_Success_DEFAULT
  1319  	}
  1320  	return *p.Success
  1321  }
  1322  
  1323  var MockExceptionTestResult_Err_DEFAULT *Exception
  1324  
  1325  func (p *MockExceptionTestResult) GetErr() (v *Exception) {
  1326  	if !p.IsSetErr() {
  1327  		return MockExceptionTestResult_Err_DEFAULT
  1328  	}
  1329  	return p.Err
  1330  }
  1331  func (p *MockExceptionTestResult) SetSuccess(x interface{}) {
  1332  	p.Success = x.(*string)
  1333  }
  1334  func (p *MockExceptionTestResult) SetErr(val *Exception) {
  1335  	p.Err = val
  1336  }
  1337  
  1338  var fieldIDToName_MockExceptionTestResult = map[int16]string{
  1339  	0: "success",
  1340  	1: "err",
  1341  }
  1342  
  1343  func (p *MockExceptionTestResult) IsSetSuccess() bool {
  1344  	return p.Success != nil
  1345  }
  1346  
  1347  func (p *MockExceptionTestResult) IsSetErr() bool {
  1348  	return p.Err != nil
  1349  }
  1350  
  1351  func (p *MockExceptionTestResult) Read(iprot thrift.TProtocol) (err error) {
  1352  
  1353  	var fieldTypeId thrift.TType
  1354  	var fieldId int16
  1355  
  1356  	if _, err = iprot.ReadStructBegin(); err != nil {
  1357  		goto ReadStructBeginError
  1358  	}
  1359  
  1360  	for {
  1361  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
  1362  		if err != nil {
  1363  			goto ReadFieldBeginError
  1364  		}
  1365  		if fieldTypeId == thrift.STOP {
  1366  			break
  1367  		}
  1368  
  1369  		switch fieldId {
  1370  		case 0:
  1371  			if fieldTypeId == thrift.STRING {
  1372  				if err = p.ReadField0(iprot); err != nil {
  1373  					goto ReadFieldError
  1374  				}
  1375  			} else {
  1376  				if err = iprot.Skip(fieldTypeId); err != nil {
  1377  					goto SkipFieldError
  1378  				}
  1379  			}
  1380  		case 1:
  1381  			if fieldTypeId == thrift.STRUCT {
  1382  				if err = p.ReadField1(iprot); err != nil {
  1383  					goto ReadFieldError
  1384  				}
  1385  			} else {
  1386  				if err = iprot.Skip(fieldTypeId); err != nil {
  1387  					goto SkipFieldError
  1388  				}
  1389  			}
  1390  		default:
  1391  			if err = iprot.Skip(fieldTypeId); err != nil {
  1392  				goto SkipFieldError
  1393  			}
  1394  		}
  1395  
  1396  		if err = iprot.ReadFieldEnd(); err != nil {
  1397  			goto ReadFieldEndError
  1398  		}
  1399  	}
  1400  	if err = iprot.ReadStructEnd(); err != nil {
  1401  		goto ReadStructEndError
  1402  	}
  1403  
  1404  	return nil
  1405  ReadStructBeginError:
  1406  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
  1407  ReadFieldBeginError:
  1408  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
  1409  ReadFieldError:
  1410  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MockExceptionTestResult[fieldId]), err)
  1411  SkipFieldError:
  1412  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
  1413  
  1414  ReadFieldEndError:
  1415  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
  1416  ReadStructEndError:
  1417  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
  1418  }
  1419  
  1420  func (p *MockExceptionTestResult) ReadField0(iprot thrift.TProtocol) error {
  1421  	if v, err := iprot.ReadString(); err != nil {
  1422  		return err
  1423  	} else {
  1424  		p.Success = &v
  1425  	}
  1426  	return nil
  1427  }
  1428  
  1429  func (p *MockExceptionTestResult) ReadField1(iprot thrift.TProtocol) error {
  1430  	p.Err = NewException()
  1431  	if err := p.Err.Read(iprot); err != nil {
  1432  		return err
  1433  	}
  1434  	return nil
  1435  }
  1436  
  1437  func (p *MockExceptionTestResult) Write(oprot thrift.TProtocol) (err error) {
  1438  	var fieldId int16
  1439  	if err = oprot.WriteStructBegin("ExceptionTest_result"); err != nil {
  1440  		goto WriteStructBeginError
  1441  	}
  1442  	if p != nil {
  1443  		if err = p.writeField0(oprot); err != nil {
  1444  			fieldId = 0
  1445  			goto WriteFieldError
  1446  		}
  1447  		if err = p.writeField1(oprot); err != nil {
  1448  			fieldId = 1
  1449  			goto WriteFieldError
  1450  		}
  1451  
  1452  	}
  1453  	if err = oprot.WriteFieldStop(); err != nil {
  1454  		goto WriteFieldStopError
  1455  	}
  1456  	if err = oprot.WriteStructEnd(); err != nil {
  1457  		goto WriteStructEndError
  1458  	}
  1459  	return nil
  1460  WriteStructBeginError:
  1461  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
  1462  WriteFieldError:
  1463  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
  1464  WriteFieldStopError:
  1465  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
  1466  WriteStructEndError:
  1467  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
  1468  }
  1469  
  1470  func (p *MockExceptionTestResult) writeField0(oprot thrift.TProtocol) (err error) {
  1471  	if p.IsSetSuccess() {
  1472  		if err = oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil {
  1473  			goto WriteFieldBeginError
  1474  		}
  1475  		if err := oprot.WriteString(*p.Success); err != nil {
  1476  			return err
  1477  		}
  1478  		if err = oprot.WriteFieldEnd(); err != nil {
  1479  			goto WriteFieldEndError
  1480  		}
  1481  	}
  1482  	return nil
  1483  WriteFieldBeginError:
  1484  	return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err)
  1485  WriteFieldEndError:
  1486  	return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err)
  1487  }
  1488  
  1489  func (p *MockExceptionTestResult) writeField1(oprot thrift.TProtocol) (err error) {
  1490  	if p.IsSetErr() {
  1491  		if err = oprot.WriteFieldBegin("err", thrift.STRUCT, 1); err != nil {
  1492  			goto WriteFieldBeginError
  1493  		}
  1494  		if err := p.Err.Write(oprot); err != nil {
  1495  			return err
  1496  		}
  1497  		if err = oprot.WriteFieldEnd(); err != nil {
  1498  			goto WriteFieldEndError
  1499  		}
  1500  	}
  1501  	return nil
  1502  WriteFieldBeginError:
  1503  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
  1504  WriteFieldEndError:
  1505  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
  1506  }
  1507  
  1508  func (p *MockExceptionTestResult) String() string {
  1509  	if p == nil {
  1510  		return "<nil>"
  1511  	}
  1512  	return fmt.Sprintf("MockExceptionTestResult(%+v)", *p)
  1513  }
  1514  
  1515  func (p *MockExceptionTestResult) DeepEqual(ano *MockExceptionTestResult) bool {
  1516  	if p == ano {
  1517  		return true
  1518  	} else if p == nil || ano == nil {
  1519  		return false
  1520  	}
  1521  	if !p.Field0DeepEqual(ano.Success) {
  1522  		return false
  1523  	}
  1524  	if !p.Field1DeepEqual(ano.Err) {
  1525  		return false
  1526  	}
  1527  	return true
  1528  }
  1529  
  1530  func (p *MockExceptionTestResult) Field0DeepEqual(src *string) bool {
  1531  
  1532  	if p.Success == src {
  1533  		return true
  1534  	} else if p.Success == nil || src == nil {
  1535  		return false
  1536  	}
  1537  	if strings.Compare(*p.Success, *src) != 0 {
  1538  		return false
  1539  	}
  1540  	return true
  1541  }
  1542  func (p *MockExceptionTestResult) Field1DeepEqual(src *Exception) bool {
  1543  
  1544  	if !p.Err.DeepEqual(src) {
  1545  		return false
  1546  	}
  1547  	return true
  1548  }