小编use*_*erx的帖子

JMockit模拟构造函数

我是一个单元测试一个具有复杂构造函数(具有大量参数)的类.构造函数有三个参数,如:

public BehavioralDischargeCarePlan_Bus(Webform webForm,String dataEntryModel, String     obsBatId) {

    super(webForm, dataEntryModel, obsBatId);
.....
Run Code Online (Sandbox Code Playgroud)

然后构造函数调用一个更复杂的超级构造函数.使用JMockit,如何在不实际调用构造函数的情况下创建类的实例并测试方法?我是JMockit的新手,任何帮助都将不胜感激.

谢谢 !

java unit-testing jmockit

11
推荐指数
1
解决办法
2万
查看次数

如何修改iOS中的图像元数据(EXIF)而不重复?

目前我使用的代码可以编写更新的元数据,但会创建一个重复的图像.这是代码:

if( [self.textView.text length] != 0 && ![self.userComments isEqualToString: self.textView.text])
        {
            // This code works but creates a duplicate image
            NSMutableDictionary *userCommentDictionary = [NSMutableDictionary dictionary];
            [userCommentDictionary setValue:self.textView.text forKey:(NSString *)kCGImagePropertyExifUserComment];

            NSMutableDictionary *dict = [NSMutableDictionary dictionary];
            [dict setValue:userCommentDictionary forKey:(NSString *)kCGImagePropertyExifDictionary];

            ALAssetsLibrary *al = [[ALAssetsLibrary alloc] init];

            [al writeImageToSavedPhotosAlbum:[self.imageView.image CGImage]
                                metadata:dict
                         completionBlock:^(NSURL *assetURL, NSError *error) {
                             if (error == nil) {
                                 NSLog(@"Image saved.");
                                 self.userComments = self.textView.text;
                             } else {
                                 NSLog(@"Error saving image.");
                             }
                         }];
        }
Run Code Online (Sandbox Code Playgroud)

反正有没有避免重复?谢谢你的时间

exif objective-c ios

4
推荐指数
1
解决办法
2015
查看次数

如何根据字段的子字符串值连接两个表?

我有sql的问题.我想加入两个表,员工和班级讲师.条件是员工有像'u0871457'这样的unid列,其中班级讲师将EmplId设为'00871457'.

我只想将EmplId的第一个字符替换为'u'来加入以匹配来自unid的字符串.我怎样才能做到这一点?到目前为止我试过这个:

select e.name, i.name
from  Employee e
inner join Instructor i on SUBSTR(e.id,1, LENGTH(e.id )) = SUBSTR(i.id,1, LENGTH(i.id ))
Run Code Online (Sandbox Code Playgroud)

但这导致结果为空白.

任何帮助将不胜感激.谢谢你的时间!

sql oracle join inner-join

4
推荐指数
1
解决办法
4万
查看次数

弹出窗口中的Angular bootstrap日期范围选择器?

我正在尝试使用ng-bootstrap在我的角度应用程序中显示日期范围选择器.我的代码如下所示:

<ngb-datepicker #dp ngModel (ngModelChange)="onDateChange($event)" [displayMonths]="2" [dayTemplate]="t">
            </ngb-datepicker>

            <ng-template #t let-date="date" let-focused="focused">
              <span class="custom-day"
                    [class.focused]="focused"
                    [class.range]="isFrom(date) || isTo(date) || isInside(date) || isHovered(date)"
                    [class.faded]="isHovered(date) || isInside(date)"
                    (mouseenter)="hoveredDate = date"
                    (mouseleave)="hoveredDate = null">
                {{ date.day }}
              </span>
            </ng-template>
Run Code Online (Sandbox Code Playgroud)

如何在弹出窗口中显示上述范围选择器?

根据答案,我尝试了以下操作,但点击时看不到弹出窗口:

 <!-- Button trigger modal -->
          <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
            Pick Date Range
           </button>

    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Optional title</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button> …
Run Code Online (Sandbox Code Playgroud)

popup bootstrap-4 ng-bootstrap angular

4
推荐指数
2
解决办法
3889
查看次数

在ios-charts中如何设置y轴的最大值?

我正在使用 ios-charts 来显示一个 Horizo​​ntal BarChart ,其中一个值是这样的:

 var dataEntries: [BarChartDataEntry] = []
        let dataEntry = BarChartDataEntry(value: self.deductible!.deductiblePaid, xIndex: 0)
        dataEntries.append(dataEntry)
        let chartDataSet =    BarChartDataSet(yVals: dataEntries, label: "Deductible")
        let chartData = BarChartData( xVals: dataPoints, dataSet: chartDataSet)


        self.horizontalBarChart!.data = chartData
        self.horizontalBarChart!.leftAxis.customAxisMax = 3000.0
        self.horizontalBarChart!.leftAxis.startAtZeroEnabled = false

        chartDataSet.colors = ChartColorTemplates.vordiplom()
Run Code Online (Sandbox Code Playgroud)

我试图为 YAxis 设置最大值,但它不影响图形。编辑:请在此处查看屏幕截图:http : //postimg.org/image/ogoj2t02f/ 我需要的是条形图应显示上限为 3000(或动态指定的数量),而不是计算出的上限。

我更改了一些代码来实现它,这是我目前所拥有的:

self.horizontalBarChart!.noDataText = "You need to provide data for the chart."

        self.horizontalBarChart!.setVisibleYRangeMaximum(3000, axis: ChartYAxis.AxisDependency.Left)
        self.horizontalBarChart!.descriptionText = ""
        var dataEntries: [BarChartDataEntry] = []
        let dataEntry = BarChartDataEntry(value: …
Run Code Online (Sandbox Code Playgroud)

ios swift mpandroidchart ios-charts

2
推荐指数
1
解决办法
9101
查看次数

如何旋转 D3 图表,使选定的弧在底部?

我正在尝试开发一个应用程序,用户可以在其中单击 D3 饼图并查看与选择相关的信息。我怎样才能旋转弧线,使点击的弧线到达底部(点击的弧线的中心应该在底部)?我一直在通过选择弧组来旋转馅饼,但我很感激有关如何实现这一点的任何想法。这是我到目前为止的一些代码。

 var self = this;
    var instanceId = Math.floor(Math.random() * 100000);

    var margin = {
        top: 5,
        right: 15,
        bottom: 50,
        left: 20
    };

    self.width = this.htmlElement.parentElement.parentElement.offsetWidth - margin.right - margin.left;
    self.height =   window.innerHeight / 3 ;
    self.curAngle = 0;

    self.svgParent.html("<h4 style='color:green;'>Sponsors </h4><br>");

    // Update data for the chart
    self.updateChartData = function () {

        if(!self.svg) {
            this.svg = this.svgParent
                .classed("svg-container", true)
                .append("svg")
                .attr("preserveAspectRatio", "xMinYMin meet")
                .attr("viewBox", "0 0 " + this.width + " " + this.height)
                .append("g")
                .classed("svg-content-responsive", …
Run Code Online (Sandbox Code Playgroud)

javascript d3.js pie-chart

2
推荐指数
1
解决办法
1555
查看次数

对于D3过渡,获取“错误,为时已晚”

我正在尝试在饼图的onClick事件中进行三个转换。第一个转换有效,但是第二个和第三个转换失败。我从Mike Bostocks的一个类似问题的评论中了解到,“ 这意味着您正在尝试修改已经开始的过渡,或者从已经结束的过渡中获得过渡。请阅读有关过渡生命周期的API参考部分。

我似乎仍然无法理解发生这种情况的原因。以下是相关代码:

self.primaryLabelText = self.arc.append("text")
    .on("click", function (d: any) {
        console.log("About to send::::" + getStudyLabel(d.index));
        self.selectedIndustryTypeService.sendMessage(getStudyLabel(d.index));
        self.showDialog();

        // The amount we need to rotate:
        var rotate = 180-(d.startAngle + d.endAngle)/2 / Math.PI * 180;

        // Transition the pie chart
        g.transition()
            .attr("transform",  "translate(" + self.width / 2 + "," + self.height / 2 + ") rotate(" + rotate + ")")
            .duration(1000);

        // ?ransition the labels:
        self.primaryLabelText.transition()
            .attr("transform", function(dd: any) {
            return "translate(" + label.centroid(dd) + ") rotate(" + …
Run Code Online (Sandbox Code Playgroud)

javascript d3.js pie-chart

1
推荐指数
1
解决办法
1544
查看次数

在Swift中,用分配的值声明变量是一种好习惯吗?

声明具有默认值的变量是否是一个好习惯:

var myBoolean = false
Run Code Online (Sandbox Code Playgroud)

还是在诸如viewDidLoad或其他委托的视图生命周期方法中初始化值更好。

override func viewDidLoad() {
    self.myBoolean = false
}
Run Code Online (Sandbox Code Playgroud)

我不知道其中之一在内存使用方面是否更好。

(我知道,如果您希望每次出现视图时都将变量设置为一个值,则可以使用viewWillAppear)。

memory-management swift

1
推荐指数
1
解决办法
55
查看次数