repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/chart/MeetingSpeakingTimeColumnChart.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MeetingMemberCursorWrapper.java // public class MeetingMemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MeetingMemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public long getMeetingId() { // return getLongField(MeetingMemberColumns.MEETING_ID); // } // // public long getMemberId() { // return getLongField(MeetingMemberColumns.MEMBER_ID); // } // // public String getMemberName() { // Integer index = getIndex(MemberColumns.NAME); // if (isNull(index)) return null; // return getString(index); // } // // public long getDuration() { // return getLongField(MeetingMemberColumns.DURATION); // } // // public long getTotalDuration() { // return getLongField(MeetingColumns.TOTAL_DURATION); // } // // public long getTalkStartTime() { // return getLongField(MeetingMemberColumns.TALK_START_TIME); // } // // public long getMeetingDate() { // return getLongField(MeetingColumns.MEETING_DATE); // } // // public State getMeetingState() { // Integer index = getIndex(MeetingColumns.STATE); // if (isNull(index)) return State.NOT_STARTED; // int stateInt = getInt(index); // return State.values()[stateInt]; // } // // private long getLongField(String columnName) { // Integer index = getIndex(columnName); // if (isNull(index)) return 0; // return getLong(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // }
import lecho.lib.hellocharts.model.Axis; import lecho.lib.hellocharts.model.AxisValue; import lecho.lib.hellocharts.model.Column; import lecho.lib.hellocharts.model.ColumnChartData; import lecho.lib.hellocharts.model.SubcolumnValue; import lecho.lib.hellocharts.view.ColumnChartView; import android.content.Context; import android.database.Cursor; import android.support.annotation.NonNull; import android.support.v4.content.res.ResourcesCompat; import android.text.format.DateUtils; import java.util.ArrayList; import java.util.List; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.provider.MeetingMemberCursorWrapper; import lecho.lib.hellocharts.gesture.ZoomType;
/* * Copyright 2016 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; /** * The meeting speaking-time chart displays the speaking time for each * member, in one meeting. Each column in the chart corresponds to the speaking time for one member, * in that meeting. */ final class MeetingSpeakingTimeColumnChart { private MeetingSpeakingTimeColumnChart() { // prevent instantiation } public static void populateMeeting(Context context, ColumnChartView chart, @NonNull Cursor cursor) { List<AxisValue> xAxisValues = new ArrayList<>(); List<Column> columns = new ArrayList<>();
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MeetingMemberCursorWrapper.java // public class MeetingMemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MeetingMemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public long getMeetingId() { // return getLongField(MeetingMemberColumns.MEETING_ID); // } // // public long getMemberId() { // return getLongField(MeetingMemberColumns.MEMBER_ID); // } // // public String getMemberName() { // Integer index = getIndex(MemberColumns.NAME); // if (isNull(index)) return null; // return getString(index); // } // // public long getDuration() { // return getLongField(MeetingMemberColumns.DURATION); // } // // public long getTotalDuration() { // return getLongField(MeetingColumns.TOTAL_DURATION); // } // // public long getTalkStartTime() { // return getLongField(MeetingMemberColumns.TALK_START_TIME); // } // // public long getMeetingDate() { // return getLongField(MeetingColumns.MEETING_DATE); // } // // public State getMeetingState() { // Integer index = getIndex(MeetingColumns.STATE); // if (isNull(index)) return State.NOT_STARTED; // int stateInt = getInt(index); // return State.values()[stateInt]; // } // // private long getLongField(String columnName) { // Integer index = getIndex(columnName); // if (isNull(index)) return 0; // return getLong(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/chart/MeetingSpeakingTimeColumnChart.java import lecho.lib.hellocharts.model.Axis; import lecho.lib.hellocharts.model.AxisValue; import lecho.lib.hellocharts.model.Column; import lecho.lib.hellocharts.model.ColumnChartData; import lecho.lib.hellocharts.model.SubcolumnValue; import lecho.lib.hellocharts.view.ColumnChartView; import android.content.Context; import android.database.Cursor; import android.support.annotation.NonNull; import android.support.v4.content.res.ResourcesCompat; import android.text.format.DateUtils; import java.util.ArrayList; import java.util.List; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.provider.MeetingMemberCursorWrapper; import lecho.lib.hellocharts.gesture.ZoomType; /* * Copyright 2016 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; /** * The meeting speaking-time chart displays the speaking time for each * member, in one meeting. Each column in the chart corresponds to the speaking time for one member, * in that meeting. */ final class MeetingSpeakingTimeColumnChart { private MeetingSpeakingTimeColumnChart() { // prevent instantiation } public static void populateMeeting(Context context, ColumnChartView chart, @NonNull Cursor cursor) { List<AxisValue> xAxisValues = new ArrayList<>(); List<Column> columns = new ArrayList<>();
MeetingMemberCursorWrapper cursorWrapper = new MeetingMemberCursorWrapper(cursor);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/provider/MeetingMemberCursorWrapper.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MeetingColumns.java // public enum State { // NOT_STARTED, IN_PROGRESS, FINISHED // }
import ca.rmen.android.scrumchatter.provider.MeetingColumns.State; import java.util.HashMap; import android.database.Cursor; import android.database.CursorWrapper;
/* * Copyright 2013 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.provider; public class MeetingMemberCursorWrapper extends CursorWrapper { private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); public MeetingMemberCursorWrapper(Cursor cursor) { super(cursor); } public long getMeetingId() { return getLongField(MeetingMemberColumns.MEETING_ID); } public long getMemberId() { return getLongField(MeetingMemberColumns.MEMBER_ID); } public String getMemberName() { Integer index = getIndex(MemberColumns.NAME); if (isNull(index)) return null; return getString(index); } public long getDuration() { return getLongField(MeetingMemberColumns.DURATION); } public long getTotalDuration() { return getLongField(MeetingColumns.TOTAL_DURATION); } public long getTalkStartTime() { return getLongField(MeetingMemberColumns.TALK_START_TIME); } public long getMeetingDate() { return getLongField(MeetingColumns.MEETING_DATE); }
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MeetingColumns.java // public enum State { // NOT_STARTED, IN_PROGRESS, FINISHED // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MeetingMemberCursorWrapper.java import ca.rmen.android.scrumchatter.provider.MeetingColumns.State; import java.util.HashMap; import android.database.Cursor; import android.database.CursorWrapper; /* * Copyright 2013 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.provider; public class MeetingMemberCursorWrapper extends CursorWrapper { private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); public MeetingMemberCursorWrapper(Cursor cursor) { super(cursor); } public long getMeetingId() { return getLongField(MeetingMemberColumns.MEETING_ID); } public long getMemberId() { return getLongField(MeetingMemberColumns.MEMBER_ID); } public String getMemberName() { Integer index = getIndex(MemberColumns.NAME); if (isNull(index)) return null; return getString(index); } public long getDuration() { return getLongField(MeetingMemberColumns.DURATION); } public long getTotalDuration() { return getLongField(MeetingColumns.TOTAL_DURATION); } public long getTalkStartTime() { return getLongField(MeetingMemberColumns.TALK_START_TIME); } public long getMeetingDate() { return getLongField(MeetingColumns.MEETING_DATE); }
public State getMeetingState() {
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/chart/MemberSpeakingTimePieChart.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MemberCursorWrapper.java // public class MemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public Long getId() { // Integer index = getColumnIndex(MemberColumns._ID); // if (isNull(index)) return null; // return getLong(index); // } // // public String getName() { // Integer index = getIndex(MemberColumns.NAME); // return getString(index); // } // // public Integer getAverageDuration() { // Integer index = getIndex(MemberStatsColumns.AVG_DURATION); // return getInt(index); // } // // public Integer getSumDuration() { // Integer index = getIndex(MemberStatsColumns.SUM_DURATION); // return getInt(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/TextUtils.java // public class TextUtils { // public static String formatDateTime(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); // } // // public static String formatDate(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL |DateUtils.FORMAT_NUMERIC_DATE); // } // // }
import ca.rmen.android.scrumchatter.provider.MemberCursorWrapper; import ca.rmen.android.scrumchatter.util.TextUtils; import lecho.lib.hellocharts.gesture.ZoomType; import lecho.lib.hellocharts.model.PieChartData; import lecho.lib.hellocharts.model.SliceValue; import lecho.lib.hellocharts.view.PieChartView; import android.content.Context; import android.database.Cursor; import android.support.annotation.NonNull; import android.text.format.DateUtils; import android.widget.TextView; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import ca.rmen.android.scrumchatter.databinding.PieChartContentBinding;
/* * Copyright 2016-2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; /** */ final class MemberSpeakingTimePieChart { private static final int MAX_VALUES = 10; private MemberSpeakingTimePieChart() { // prevent instantiation } /** * The library's SliceValue doesn't have a field for what to display in the legend for a slice. * So, we create our own class containing both the SliceValue and the legend label for a given slice. */ private static class PieChartSlice { final SliceValue sliceValue; final String legendLabel; public PieChartSlice(SliceValue sliceValue, String legendLabel) { this.sliceValue = sliceValue; this.legendLabel = legendLabel; } } public static void populateMemberSpeakingTimeChart(Context context, PieChartContentBinding pieChartAvgBinding, PieChartContentBinding pieChartTotalBinding, @NonNull Cursor cursor) { List<PieChartSlice> sliceValuesAvgSpeakingTime = new ArrayList<>(); List<PieChartSlice> sliceValuesTotalSpeakingTime = new ArrayList<>();
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MemberCursorWrapper.java // public class MemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public Long getId() { // Integer index = getColumnIndex(MemberColumns._ID); // if (isNull(index)) return null; // return getLong(index); // } // // public String getName() { // Integer index = getIndex(MemberColumns.NAME); // return getString(index); // } // // public Integer getAverageDuration() { // Integer index = getIndex(MemberStatsColumns.AVG_DURATION); // return getInt(index); // } // // public Integer getSumDuration() { // Integer index = getIndex(MemberStatsColumns.SUM_DURATION); // return getInt(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/TextUtils.java // public class TextUtils { // public static String formatDateTime(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); // } // // public static String formatDate(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL |DateUtils.FORMAT_NUMERIC_DATE); // } // // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/chart/MemberSpeakingTimePieChart.java import ca.rmen.android.scrumchatter.provider.MemberCursorWrapper; import ca.rmen.android.scrumchatter.util.TextUtils; import lecho.lib.hellocharts.gesture.ZoomType; import lecho.lib.hellocharts.model.PieChartData; import lecho.lib.hellocharts.model.SliceValue; import lecho.lib.hellocharts.view.PieChartView; import android.content.Context; import android.database.Cursor; import android.support.annotation.NonNull; import android.text.format.DateUtils; import android.widget.TextView; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import ca.rmen.android.scrumchatter.databinding.PieChartContentBinding; /* * Copyright 2016-2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; /** */ final class MemberSpeakingTimePieChart { private static final int MAX_VALUES = 10; private MemberSpeakingTimePieChart() { // prevent instantiation } /** * The library's SliceValue doesn't have a field for what to display in the legend for a slice. * So, we create our own class containing both the SliceValue and the legend label for a given slice. */ private static class PieChartSlice { final SliceValue sliceValue; final String legendLabel; public PieChartSlice(SliceValue sliceValue, String legendLabel) { this.sliceValue = sliceValue; this.legendLabel = legendLabel; } } public static void populateMemberSpeakingTimeChart(Context context, PieChartContentBinding pieChartAvgBinding, PieChartContentBinding pieChartTotalBinding, @NonNull Cursor cursor) { List<PieChartSlice> sliceValuesAvgSpeakingTime = new ArrayList<>(); List<PieChartSlice> sliceValuesTotalSpeakingTime = new ArrayList<>();
MemberCursorWrapper cursorWrapper = new MemberCursorWrapper(cursor);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/chart/MemberSpeakingTimePieChart.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MemberCursorWrapper.java // public class MemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public Long getId() { // Integer index = getColumnIndex(MemberColumns._ID); // if (isNull(index)) return null; // return getLong(index); // } // // public String getName() { // Integer index = getIndex(MemberColumns.NAME); // return getString(index); // } // // public Integer getAverageDuration() { // Integer index = getIndex(MemberStatsColumns.AVG_DURATION); // return getInt(index); // } // // public Integer getSumDuration() { // Integer index = getIndex(MemberStatsColumns.SUM_DURATION); // return getInt(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/TextUtils.java // public class TextUtils { // public static String formatDateTime(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); // } // // public static String formatDate(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL |DateUtils.FORMAT_NUMERIC_DATE); // } // // }
import ca.rmen.android.scrumchatter.provider.MemberCursorWrapper; import ca.rmen.android.scrumchatter.util.TextUtils; import lecho.lib.hellocharts.gesture.ZoomType; import lecho.lib.hellocharts.model.PieChartData; import lecho.lib.hellocharts.model.SliceValue; import lecho.lib.hellocharts.view.PieChartView; import android.content.Context; import android.database.Cursor; import android.support.annotation.NonNull; import android.text.format.DateUtils; import android.widget.TextView; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import ca.rmen.android.scrumchatter.databinding.PieChartContentBinding;
MemberCursorWrapper cursorWrapper = new MemberCursorWrapper(cursor); while (cursorWrapper.moveToNext()) { String memberName = cursorWrapper.getName(); sliceValuesAvgSpeakingTime.add(createPieChartSlice( context, cursorWrapper.getAverageDuration(), cursorWrapper.getId(), memberName)); sliceValuesTotalSpeakingTime.add(createPieChartSlice( context, cursorWrapper.getSumDuration(), cursorWrapper.getId(), memberName)); } cursor.moveToPosition(-1); setupChart(context, pieChartAvgBinding, sliceValuesAvgSpeakingTime); setupChart(context, pieChartTotalBinding, sliceValuesTotalSpeakingTime); } static void updateMeetingDateRanges(Context context, TextView tvPieChartAvgSubtitle, TextView tvPieChartTotalSubtitle, Cursor cursor) { if (cursor.moveToFirst()) { long minDate = cursor.getLong(0); long maxDate = cursor.getLong(1);
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MemberCursorWrapper.java // public class MemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public Long getId() { // Integer index = getColumnIndex(MemberColumns._ID); // if (isNull(index)) return null; // return getLong(index); // } // // public String getName() { // Integer index = getIndex(MemberColumns.NAME); // return getString(index); // } // // public Integer getAverageDuration() { // Integer index = getIndex(MemberStatsColumns.AVG_DURATION); // return getInt(index); // } // // public Integer getSumDuration() { // Integer index = getIndex(MemberStatsColumns.SUM_DURATION); // return getInt(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/TextUtils.java // public class TextUtils { // public static String formatDateTime(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); // } // // public static String formatDate(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL |DateUtils.FORMAT_NUMERIC_DATE); // } // // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/chart/MemberSpeakingTimePieChart.java import ca.rmen.android.scrumchatter.provider.MemberCursorWrapper; import ca.rmen.android.scrumchatter.util.TextUtils; import lecho.lib.hellocharts.gesture.ZoomType; import lecho.lib.hellocharts.model.PieChartData; import lecho.lib.hellocharts.model.SliceValue; import lecho.lib.hellocharts.view.PieChartView; import android.content.Context; import android.database.Cursor; import android.support.annotation.NonNull; import android.text.format.DateUtils; import android.widget.TextView; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import ca.rmen.android.scrumchatter.databinding.PieChartContentBinding; MemberCursorWrapper cursorWrapper = new MemberCursorWrapper(cursor); while (cursorWrapper.moveToNext()) { String memberName = cursorWrapper.getName(); sliceValuesAvgSpeakingTime.add(createPieChartSlice( context, cursorWrapper.getAverageDuration(), cursorWrapper.getId(), memberName)); sliceValuesTotalSpeakingTime.add(createPieChartSlice( context, cursorWrapper.getSumDuration(), cursorWrapper.getId(), memberName)); } cursor.moveToPosition(-1); setupChart(context, pieChartAvgBinding, sliceValuesAvgSpeakingTime); setupChart(context, pieChartTotalBinding, sliceValuesTotalSpeakingTime); } static void updateMeetingDateRanges(Context context, TextView tvPieChartAvgSubtitle, TextView tvPieChartTotalSubtitle, Cursor cursor) { if (cursor.moveToFirst()) { long minDate = cursor.getLong(0); long maxDate = cursor.getLong(1);
String minDateStr = TextUtils.formatDate(context, minDate);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/dialog/DialogFragmentFactory.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/dialog/ChoiceDialogFragment.java // public interface DialogItemListener { // void onItemSelected(int actionId, CharSequence[] choices, int which); // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/dialog/ConfirmDialogFragment.java // public interface DialogButtonListener { // void onOkClicked(int actionId, Bundle extras); // }
import java.util.Arrays; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.dialog.ChoiceDialogFragment.DialogItemListener; import ca.rmen.android.scrumchatter.dialog.ConfirmDialogFragment.DialogButtonListener;
/* * Copyright 2013-2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * Create different types of dialog fragments (edit text input, information, choice, confirmation, progress). * The dialogs created by this class are not only created but also shown in the activity given to the creation methods. */ public class DialogFragmentFactory extends DialogFragment { private static final String TAG = Constants.TAG + "/" + DialogFragmentFactory.class.getSimpleName(); static final String EXTRA_TITLE = "title"; static final String EXTRA_MESSAGE = "message"; static final String EXTRA_ACTION_ID = "action_id"; static final String EXTRA_CHOICES = "choices"; static final String EXTRA_SELECTED_ITEM = "selected_item"; static final String EXTRA_EXTRAS = "extras"; static final String EXTRA_INPUT_HINT = "input_hint"; static final String EXTRA_INPUT_VALIDATOR_CLASS = "input_validator_class"; static final String EXTRA_ENTERED_TEXT = "entered_text"; /** * @param inputValidatorClass will be called with each text event on the edit text, to validate the user's input. */ public static void showInputDialog(FragmentActivity activity, String title, String inputHint, String prefilledText, Class<?> inputValidatorClass, int actionId, Bundle extras) {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/dialog/ChoiceDialogFragment.java // public interface DialogItemListener { // void onItemSelected(int actionId, CharSequence[] choices, int which); // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/dialog/ConfirmDialogFragment.java // public interface DialogButtonListener { // void onOkClicked(int actionId, Bundle extras); // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/dialog/DialogFragmentFactory.java import java.util.Arrays; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.dialog.ChoiceDialogFragment.DialogItemListener; import ca.rmen.android.scrumchatter.dialog.ConfirmDialogFragment.DialogButtonListener; /* * Copyright 2013-2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * Create different types of dialog fragments (edit text input, information, choice, confirmation, progress). * The dialogs created by this class are not only created but also shown in the activity given to the creation methods. */ public class DialogFragmentFactory extends DialogFragment { private static final String TAG = Constants.TAG + "/" + DialogFragmentFactory.class.getSimpleName(); static final String EXTRA_TITLE = "title"; static final String EXTRA_MESSAGE = "message"; static final String EXTRA_ACTION_ID = "action_id"; static final String EXTRA_CHOICES = "choices"; static final String EXTRA_SELECTED_ITEM = "selected_item"; static final String EXTRA_EXTRAS = "extras"; static final String EXTRA_INPUT_HINT = "input_hint"; static final String EXTRA_INPUT_VALIDATOR_CLASS = "input_validator_class"; static final String EXTRA_ENTERED_TEXT = "entered_text"; /** * @param inputValidatorClass will be called with each text event on the edit text, to validate the user's input. */ public static void showInputDialog(FragmentActivity activity, String title, String inputHint, String prefilledText, Class<?> inputValidatorClass, int actionId, Bundle extras) {
Log.v(TAG, "showInputDialog: title = " + title + ", prefilledText = " + prefilledText + ", actionId = " + actionId + ", extras = " + extras);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/chart/MeetingChartActivity.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/meeting/Meetings.java // public class Meetings { // private static final String TAG = Constants.TAG + "/" + Meetings.class.getSimpleName(); // public static final String EXTRA_MEETING_ID = "meeting_id"; // public static final String EXTRA_MEETING_STATE = "meeting_state"; // private final FragmentActivity mActivity; // // public Meetings(FragmentActivity activity) { // mActivity = activity; // } // // /** // * Checks if there are any team members in the given team id. If not, an error dialog is shown. If the team does have members, then we start // * the MeetingActivity class for a new meeting. // */ // public Single<Meeting> createMeeting(final int teamId) { // Log.v(TAG, "createMeeting in team " + teamId); // return Single.fromCallable(() -> { // Cursor c = mActivity.getContentResolver().query(MemberColumns.CONTENT_URI, new String[]{"count(*)"}, // MemberColumns.TEAM_ID + "=? AND " + MemberColumns.DELETED + "= 0", new String[]{String.valueOf(teamId)}, null); // if (c != null) { // try { // c.moveToFirst(); // int memberCount = c.getInt(0); // if (memberCount > 0) return Meeting.createNewMeeting(mActivity); // } finally { // c.close(); // } // } // throw new IllegalArgumentException("Can't create meeting for team " + teamId + " because it doesn't exist or has no members"); // }) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()); // } // // public Single<Meeting> readMeeting(long meetingId) { // return Single.fromCallable(() -> Meeting.read(mActivity, meetingId)) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()); // } // // /** // * Shows a confirmation dialog to delete the given meeting. // */ // public void confirmDelete(final Meeting meeting) { // Log.v(TAG, "confirm delete meeting: " + meeting); // // Let's ask him if he's sure first. // Bundle extras = new Bundle(1); // extras.putLong(EXTRA_MEETING_ID, meeting.getId()); // DialogFragmentFactory.showConfirmDialog(mActivity, mActivity.getString(R.string.action_delete_meeting), // mActivity.getString(R.string.dialog_message_delete_meeting_confirm, TextUtils.formatDateTime(mActivity, meeting.getStartDate())), // R.id.action_delete_meeting, extras); // } // // /** // * Deletes the given meeting from the DB. // */ // public void delete(final long meetingId) { // Log.v(TAG, "delete meeting " + meetingId); // // Delete the meeting in a background thread. // Single.fromCallable(() -> Meeting.read(mActivity, meetingId)) // .subscribeOn(Schedulers.io()) // .observeOn(Schedulers.io()) // .subscribe(Meeting::delete, // throwable -> Log.v(TAG, "couldn't delete meeting " + meetingId, throwable)); // } // // /** // * Read the data for the given meeting, then show an intent chooser to export this data as text. // */ // public void export(long meetingId) { // Log.v(TAG, "export meeting " + meetingId); // // Export the meeting in a background thread. // Single.fromCallable(() -> new MeetingExport(mActivity).exportMeeting(meetingId)) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(success -> { // if (!success) Snackbar.make(mActivity.getWindow().getDecorView().getRootView(), R.string.error_sharing_meeting, Snackbar.LENGTH_LONG).show(); // }); // } // }
import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.meeting.Meetings;
/* * Copyright 2016 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; /** * Displays charts for all meetings. */ public class MeetingChartActivity extends AppCompatActivity { public static void start(Context context, long meetingId) { Intent intent = new Intent(context, MeetingChartActivity.class);
// Path: app/src/main/java/ca/rmen/android/scrumchatter/meeting/Meetings.java // public class Meetings { // private static final String TAG = Constants.TAG + "/" + Meetings.class.getSimpleName(); // public static final String EXTRA_MEETING_ID = "meeting_id"; // public static final String EXTRA_MEETING_STATE = "meeting_state"; // private final FragmentActivity mActivity; // // public Meetings(FragmentActivity activity) { // mActivity = activity; // } // // /** // * Checks if there are any team members in the given team id. If not, an error dialog is shown. If the team does have members, then we start // * the MeetingActivity class for a new meeting. // */ // public Single<Meeting> createMeeting(final int teamId) { // Log.v(TAG, "createMeeting in team " + teamId); // return Single.fromCallable(() -> { // Cursor c = mActivity.getContentResolver().query(MemberColumns.CONTENT_URI, new String[]{"count(*)"}, // MemberColumns.TEAM_ID + "=? AND " + MemberColumns.DELETED + "= 0", new String[]{String.valueOf(teamId)}, null); // if (c != null) { // try { // c.moveToFirst(); // int memberCount = c.getInt(0); // if (memberCount > 0) return Meeting.createNewMeeting(mActivity); // } finally { // c.close(); // } // } // throw new IllegalArgumentException("Can't create meeting for team " + teamId + " because it doesn't exist or has no members"); // }) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()); // } // // public Single<Meeting> readMeeting(long meetingId) { // return Single.fromCallable(() -> Meeting.read(mActivity, meetingId)) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()); // } // // /** // * Shows a confirmation dialog to delete the given meeting. // */ // public void confirmDelete(final Meeting meeting) { // Log.v(TAG, "confirm delete meeting: " + meeting); // // Let's ask him if he's sure first. // Bundle extras = new Bundle(1); // extras.putLong(EXTRA_MEETING_ID, meeting.getId()); // DialogFragmentFactory.showConfirmDialog(mActivity, mActivity.getString(R.string.action_delete_meeting), // mActivity.getString(R.string.dialog_message_delete_meeting_confirm, TextUtils.formatDateTime(mActivity, meeting.getStartDate())), // R.id.action_delete_meeting, extras); // } // // /** // * Deletes the given meeting from the DB. // */ // public void delete(final long meetingId) { // Log.v(TAG, "delete meeting " + meetingId); // // Delete the meeting in a background thread. // Single.fromCallable(() -> Meeting.read(mActivity, meetingId)) // .subscribeOn(Schedulers.io()) // .observeOn(Schedulers.io()) // .subscribe(Meeting::delete, // throwable -> Log.v(TAG, "couldn't delete meeting " + meetingId, throwable)); // } // // /** // * Read the data for the given meeting, then show an intent chooser to export this data as text. // */ // public void export(long meetingId) { // Log.v(TAG, "export meeting " + meetingId); // // Export the meeting in a background thread. // Single.fromCallable(() -> new MeetingExport(mActivity).exportMeeting(meetingId)) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(success -> { // if (!success) Snackbar.make(mActivity.getWindow().getDecorView().getRootView(), R.string.error_sharing_meeting, Snackbar.LENGTH_LONG).show(); // }); // } // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/chart/MeetingChartActivity.java import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.meeting.Meetings; /* * Copyright 2016 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; /** * Displays charts for all meetings. */ public class MeetingChartActivity extends AppCompatActivity { public static void start(Context context, long meetingId) { Intent intent = new Intent(context, MeetingChartActivity.class);
intent.putExtra(Meetings.EXTRA_MEETING_ID, meetingId);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/dialog/InputDialogFragment.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // }
import android.app.Dialog; import android.content.Context; import android.content.DialogInterface.OnClickListener; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; import android.text.Editable; import android.text.InputType; import android.text.TextUtils; import android.text.TextWatcher; import ca.rmen.android.scrumchatter.databinding.InputDialogEditTextBinding; import ca.rmen.android.scrumchatter.util.Log; import android.view.LayoutInflater; import android.view.Window; import android.view.WindowManager; import android.widget.Button; import android.widget.EditText; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.R; import io.reactivex.Maybe; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers;
/* * Copyright 2013, 2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * A dialog fragment with an EditText for user text input. */ public class InputDialogFragment extends DialogFragment { // NO_UCD (use default) private static final String TAG = Constants.TAG + "/" + InputDialogFragment.class.getSimpleName(); private String mEnteredText; public interface InputValidator { /** * @param input the text entered by the user. * @return an error string if the input has a problem, null if the input is valid. */ @WorkerThread @Nullable String getError(Context context, CharSequence input, Bundle extras); } /** * The activity owning this dialog fragment should implement this interface to be notified when the user submits entered text. */ public interface DialogInputListener { void onInputEntered(int actionId, String input, Bundle extras); } public InputDialogFragment() { super(); } @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/dialog/InputDialogFragment.java import android.app.Dialog; import android.content.Context; import android.content.DialogInterface.OnClickListener; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; import android.text.Editable; import android.text.InputType; import android.text.TextUtils; import android.text.TextWatcher; import ca.rmen.android.scrumchatter.databinding.InputDialogEditTextBinding; import ca.rmen.android.scrumchatter.util.Log; import android.view.LayoutInflater; import android.view.Window; import android.view.WindowManager; import android.widget.Button; import android.widget.EditText; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.R; import io.reactivex.Maybe; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; /* * Copyright 2013, 2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * A dialog fragment with an EditText for user text input. */ public class InputDialogFragment extends DialogFragment { // NO_UCD (use default) private static final String TAG = Constants.TAG + "/" + InputDialogFragment.class.getSimpleName(); private String mEnteredText; public interface InputValidator { /** * @param input the text entered by the user. * @return an error string if the input has a problem, null if the input is valid. */ @WorkerThread @Nullable String getError(Context context, CharSequence input, Bundle extras); } /** * The activity owning this dialog fragment should implement this interface to be notified when the user submits entered text. */ public interface DialogInputListener { void onInputEntered(int actionId, String input, Bundle extras); } public InputDialogFragment() { super(); } @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) {
Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/settings/Theme.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // }
import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; import android.support.v7.app.AppCompatDelegate; import android.util.Log; import ca.rmen.android.scrumchatter.Constants; import io.reactivex.Single; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers;
/* * Copyright 2016 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.settings; @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public class Theme {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/settings/Theme.java import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; import android.support.v7.app.AppCompatDelegate; import android.util.Log; import ca.rmen.android.scrumchatter.Constants; import io.reactivex.Single; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; /* * Copyright 2016 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.settings; @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public class Theme {
private static final String TAG = Constants.TAG + Theme.class.getSimpleName();
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/settings/Prefs.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/StrictModeUtil.java // public class StrictModeUtil { // private static final String TAG = Constants.TAG + "/" + StrictModeUtil.class.getName(); // private StrictModeUtil() { // // prevent instantiation // } // // public static void enable() { // Log.v(TAG, "enable"); // // Use strict mode for monkey tests. We can't enable strict mode for normal use // // because, when sharing (exporting), the mail app may read the attachment in // // the main thread. // if (ActivityManager.isUserAMonkey()) { // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().penaltyLog().penaltyDeath().build()); // } // } // // public static void disable() { // Log.v(TAG, "disable"); // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build()); // } // // }
import android.content.Context; import android.content.SharedPreferences; import android.os.Looper; import android.preference.PreferenceManager; import android.support.annotation.NonNull; import java.util.Map; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.util.StrictModeUtil;
/* * Copyright 2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.settings; public final class Prefs { enum Theme { Dark, Light, Auto } static final String PREF_THEME = "PREF_THEME";
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/StrictModeUtil.java // public class StrictModeUtil { // private static final String TAG = Constants.TAG + "/" + StrictModeUtil.class.getName(); // private StrictModeUtil() { // // prevent instantiation // } // // public static void enable() { // Log.v(TAG, "enable"); // // Use strict mode for monkey tests. We can't enable strict mode for normal use // // because, when sharing (exporting), the mail app may read the attachment in // // the main thread. // if (ActivityManager.isUserAMonkey()) { // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().penaltyLog().penaltyDeath().build()); // } // } // // public static void disable() { // Log.v(TAG, "disable"); // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build()); // } // // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/settings/Prefs.java import android.content.Context; import android.content.SharedPreferences; import android.os.Looper; import android.preference.PreferenceManager; import android.support.annotation.NonNull; import java.util.Map; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.util.StrictModeUtil; /* * Copyright 2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.settings; public final class Prefs { enum Theme { Dark, Light, Auto } static final String PREF_THEME = "PREF_THEME";
private static final String TAG = Constants.TAG + "/" + Prefs.class.getSimpleName();
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/settings/Prefs.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/StrictModeUtil.java // public class StrictModeUtil { // private static final String TAG = Constants.TAG + "/" + StrictModeUtil.class.getName(); // private StrictModeUtil() { // // prevent instantiation // } // // public static void enable() { // Log.v(TAG, "enable"); // // Use strict mode for monkey tests. We can't enable strict mode for normal use // // because, when sharing (exporting), the mail app may read the attachment in // // the main thread. // if (ActivityManager.isUserAMonkey()) { // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().penaltyLog().penaltyDeath().build()); // } // } // // public static void disable() { // Log.v(TAG, "disable"); // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build()); // } // // }
import android.content.Context; import android.content.SharedPreferences; import android.os.Looper; import android.preference.PreferenceManager; import android.support.annotation.NonNull; import java.util.Map; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.util.StrictModeUtil;
/* * Copyright 2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.settings; public final class Prefs { enum Theme { Dark, Light, Auto } static final String PREF_THEME = "PREF_THEME"; private static final String TAG = Constants.TAG + "/" + Prefs.class.getSimpleName(); private static Prefs INSTANCE; private final SharedPreferences mPrefs; private Prefs(Context context) { // We try to behave by not reading from the disk on the ui thread. But one exception // we can allow is to read the shared prefs one time when this singleton is initialized boolean cheatIgnoreStrictModeViolations = Looper.getMainLooper().getThread() == Thread.currentThread();
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/StrictModeUtil.java // public class StrictModeUtil { // private static final String TAG = Constants.TAG + "/" + StrictModeUtil.class.getName(); // private StrictModeUtil() { // // prevent instantiation // } // // public static void enable() { // Log.v(TAG, "enable"); // // Use strict mode for monkey tests. We can't enable strict mode for normal use // // because, when sharing (exporting), the mail app may read the attachment in // // the main thread. // if (ActivityManager.isUserAMonkey()) { // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().penaltyLog().penaltyDeath().build()); // } // } // // public static void disable() { // Log.v(TAG, "disable"); // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build()); // } // // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/settings/Prefs.java import android.content.Context; import android.content.SharedPreferences; import android.os.Looper; import android.preference.PreferenceManager; import android.support.annotation.NonNull; import java.util.Map; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.util.StrictModeUtil; /* * Copyright 2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.settings; public final class Prefs { enum Theme { Dark, Light, Auto } static final String PREF_THEME = "PREF_THEME"; private static final String TAG = Constants.TAG + "/" + Prefs.class.getSimpleName(); private static Prefs INSTANCE; private final SharedPreferences mPrefs; private Prefs(Context context) { // We try to behave by not reading from the disk on the ui thread. But one exception // we can allow is to read the shared prefs one time when this singleton is initialized boolean cheatIgnoreStrictModeViolations = Looper.getMainLooper().getThread() == Thread.currentThread();
if (cheatIgnoreStrictModeViolations) StrictModeUtil.disable();
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/settings/Prefs.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/StrictModeUtil.java // public class StrictModeUtil { // private static final String TAG = Constants.TAG + "/" + StrictModeUtil.class.getName(); // private StrictModeUtil() { // // prevent instantiation // } // // public static void enable() { // Log.v(TAG, "enable"); // // Use strict mode for monkey tests. We can't enable strict mode for normal use // // because, when sharing (exporting), the mail app may read the attachment in // // the main thread. // if (ActivityManager.isUserAMonkey()) { // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().penaltyLog().penaltyDeath().build()); // } // } // // public static void disable() { // Log.v(TAG, "disable"); // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build()); // } // // }
import android.content.Context; import android.content.SharedPreferences; import android.os.Looper; import android.preference.PreferenceManager; import android.support.annotation.NonNull; import java.util.Map; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.util.StrictModeUtil;
/* * Copyright 2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.settings; public final class Prefs { enum Theme { Dark, Light, Auto } static final String PREF_THEME = "PREF_THEME"; private static final String TAG = Constants.TAG + "/" + Prefs.class.getSimpleName(); private static Prefs INSTANCE; private final SharedPreferences mPrefs; private Prefs(Context context) { // We try to behave by not reading from the disk on the ui thread. But one exception // we can allow is to read the shared prefs one time when this singleton is initialized boolean cheatIgnoreStrictModeViolations = Looper.getMainLooper().getThread() == Thread.currentThread(); if (cheatIgnoreStrictModeViolations) StrictModeUtil.disable(); mPrefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); Map<String, ?> allPrefs = mPrefs.getAll();
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/StrictModeUtil.java // public class StrictModeUtil { // private static final String TAG = Constants.TAG + "/" + StrictModeUtil.class.getName(); // private StrictModeUtil() { // // prevent instantiation // } // // public static void enable() { // Log.v(TAG, "enable"); // // Use strict mode for monkey tests. We can't enable strict mode for normal use // // because, when sharing (exporting), the mail app may read the attachment in // // the main thread. // if (ActivityManager.isUserAMonkey()) { // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().penaltyLog().penaltyDeath().build()); // } // } // // public static void disable() { // Log.v(TAG, "disable"); // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build()); // } // // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/settings/Prefs.java import android.content.Context; import android.content.SharedPreferences; import android.os.Looper; import android.preference.PreferenceManager; import android.support.annotation.NonNull; import java.util.Map; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.util.StrictModeUtil; /* * Copyright 2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.settings; public final class Prefs { enum Theme { Dark, Light, Auto } static final String PREF_THEME = "PREF_THEME"; private static final String TAG = Constants.TAG + "/" + Prefs.class.getSimpleName(); private static Prefs INSTANCE; private final SharedPreferences mPrefs; private Prefs(Context context) { // We try to behave by not reading from the disk on the ui thread. But one exception // we can allow is to read the shared prefs one time when this singleton is initialized boolean cheatIgnoreStrictModeViolations = Looper.getMainLooper().getThread() == Thread.currentThread(); if (cheatIgnoreStrictModeViolations) StrictModeUtil.disable(); mPrefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); Map<String, ?> allPrefs = mPrefs.getAll();
Log.v(TAG, "Read prefs " + allPrefs);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/dialog/ConfirmDialogFragment.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // }
import android.app.Dialog; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.Constants;
/* * Copyright 2013, 2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * A dialog fragment with a title, message, ok and cancel buttons. */ public class ConfirmDialogFragment extends DialogFragment { // NO_UCD (use default) private static final String TAG = Constants.TAG + "/" + ConfirmDialogFragment.class.getSimpleName(); /** * An activity which contains a confirmation dialog fragment should implement this interface to be notified if the user clicks ok on the dialog. */ public interface DialogButtonListener { void onOkClicked(int actionId, Bundle extras); } public ConfirmDialogFragment() { super(); } /** * @return an AlertDialog with a title, message, ok, and cancel buttons. */ @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/dialog/ConfirmDialogFragment.java import android.app.Dialog; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; import ca.rmen.android.scrumchatter.util.Log; import ca.rmen.android.scrumchatter.Constants; /* * Copyright 2013, 2017 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.dialog; /** * A dialog fragment with a title, message, ok and cancel buttons. */ public class ConfirmDialogFragment extends DialogFragment { // NO_UCD (use default) private static final String TAG = Constants.TAG + "/" + ConfirmDialogFragment.class.getSimpleName(); /** * An activity which contains a confirmation dialog fragment should implement this interface to be notified if the user clicks ok on the dialog. */ public interface DialogButtonListener { void onOkClicked(int actionId, Bundle extras); } public ConfirmDialogFragment() { super(); } /** * @return an AlertDialog with a title, message, ok, and cancel buttons. */ @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) {
Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/provider/ScrumChatterProvider.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // }
import android.content.ContentProvider; import android.content.ContentProviderOperation; import android.content.ContentProviderResult; import android.content.ContentValues; import android.content.Context; import android.content.OperationApplicationException; import android.content.UriMatcher; import android.database.Cursor; import android.database.sqlite.SQLiteCursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQuery; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import android.provider.BaseColumns; import android.support.annotation.NonNull; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; import io.reactivex.Observable;
switch (match) { case URI_TYPE_TEAM: return TYPE_CURSOR_DIR + TeamColumns.TABLE_NAME; case URI_TYPE_TEAM_ID: return TYPE_CURSOR_ITEM + TeamColumns.TABLE_NAME; case URI_TYPE_MEETING_MEMBER: return TYPE_CURSOR_DIR + MeetingMemberColumns.TABLE_NAME; case URI_TYPE_MEETING_MEMBER_ID: return TYPE_CURSOR_ITEM + MeetingMemberColumns.TABLE_NAME; case URI_TYPE_MEMBER: return TYPE_CURSOR_DIR + MemberColumns.TABLE_NAME; case URI_TYPE_MEMBER_ID: return TYPE_CURSOR_ITEM + MemberColumns.TABLE_NAME; case URI_TYPE_MEETING: return TYPE_CURSOR_DIR + MeetingColumns.TABLE_NAME; case URI_TYPE_MEETING_ID: return TYPE_CURSOR_ITEM + MeetingColumns.TABLE_NAME; case URI_TYPE_MEMBER_STATS: return TYPE_CURSOR_ITEM + MemberStatsColumns.VIEW_NAME; } return null; } @Override public Uri insert(@NonNull Uri uri, ContentValues values) {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/Constants.java // public class Constants { // public static final String TAG = "ScrumChatter"; // public static final String PREF_TEAM_ID = "team_id"; // public static final int DEFAULT_TEAM_ID = 1; // public static final String DEFAULT_TEAM_NAME = "Team A"; // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/Log.java // @SuppressWarnings("unused") // public class Log { // public static void v(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message); // } // // public static void v(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.v(tag, message, t); // } // // public static void d(String tag, String message) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message); // } // // public static void d(String tag, String message, Throwable t) { // if (BuildConfig.DEBUG) android.util.Log.d(tag, message, t); // } // // public static void i(String tag, String message) { // android.util.Log.i(tag, message); // } // // public static void i(String tag, String message, Throwable t) { // android.util.Log.i(tag, message, t); // } // // public static void w(String tag, String message) { // android.util.Log.w(tag, message); // } // // public static void w(String tag, String message, Throwable t) { // android.util.Log.w(tag, message, t); // } // // public static void e(String tag, String message) { // android.util.Log.e(tag, message); // } // // public static void e(String tag, String message, Throwable t) { // android.util.Log.e(tag, message, t); // } // // public static void wtf(String tag, String message) { // android.util.Log.wtf(tag, message); // } // // public static void wtf(String tag, String message, Throwable t) { // android.util.Log.wtf(tag, message, t); // } // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/ScrumChatterProvider.java import android.content.ContentProvider; import android.content.ContentProviderOperation; import android.content.ContentProviderResult; import android.content.ContentValues; import android.content.Context; import android.content.OperationApplicationException; import android.content.UriMatcher; import android.database.Cursor; import android.database.sqlite.SQLiteCursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQuery; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import android.provider.BaseColumns; import android.support.annotation.NonNull; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import ca.rmen.android.scrumchatter.Constants; import ca.rmen.android.scrumchatter.util.Log; import io.reactivex.Observable; switch (match) { case URI_TYPE_TEAM: return TYPE_CURSOR_DIR + TeamColumns.TABLE_NAME; case URI_TYPE_TEAM_ID: return TYPE_CURSOR_ITEM + TeamColumns.TABLE_NAME; case URI_TYPE_MEETING_MEMBER: return TYPE_CURSOR_DIR + MeetingMemberColumns.TABLE_NAME; case URI_TYPE_MEETING_MEMBER_ID: return TYPE_CURSOR_ITEM + MeetingMemberColumns.TABLE_NAME; case URI_TYPE_MEMBER: return TYPE_CURSOR_DIR + MemberColumns.TABLE_NAME; case URI_TYPE_MEMBER_ID: return TYPE_CURSOR_ITEM + MemberColumns.TABLE_NAME; case URI_TYPE_MEETING: return TYPE_CURSOR_DIR + MeetingColumns.TABLE_NAME; case URI_TYPE_MEETING_ID: return TYPE_CURSOR_ITEM + MeetingColumns.TABLE_NAME; case URI_TYPE_MEMBER_STATS: return TYPE_CURSOR_ITEM + MemberStatsColumns.VIEW_NAME; } return null; } @Override public Uri insert(@NonNull Uri uri, ContentValues values) {
Log.d(TAG, "insert uri=" + uri + " values=" + values);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/member/list/MembersCursorAdapter.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/member/list/Members.java // public static class Member { // private final long id; // private final String name; // // Member(long memberId, String memberName) { // this.id = memberId; // this.name = memberName; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MemberCursorWrapper.java // public class MemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public Long getId() { // Integer index = getColumnIndex(MemberColumns._ID); // if (isNull(index)) return null; // return getLong(index); // } // // public String getName() { // Integer index = getIndex(MemberColumns.NAME); // return getString(index); // } // // public Integer getAverageDuration() { // Integer index = getIndex(MemberStatsColumns.AVG_DURATION); // return getInt(index); // } // // public Integer getSumDuration() { // Integer index = getIndex(MemberStatsColumns.SUM_DURATION); // return getInt(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/widget/ScrumChatterCursorAdapter.java // public abstract class ScrumChatterCursorAdapter<T extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<T> { // // private Cursor mCursor; // // protected ScrumChatterCursorAdapter() { // setHasStableIds(true); // } // public void changeCursor(Cursor cursor) { // if (mCursor == cursor) return; // mCursor = cursor; // notifyDataSetChanged(); // } // // @Override // public long getItemId(int position) { // if (mCursor == null || !mCursor.moveToPosition(position)) { // return RecyclerView.NO_ID; // } // return mCursor.getLong(mCursor.getColumnIndex(BaseColumns._ID)); // } // // @Override // public int getItemCount() { // if (mCursor == null) return 0; // else return mCursor.getCount(); // } // // protected Cursor getCursor() { // return mCursor; // } // }
import android.databinding.DataBindingUtil; import android.support.v7.widget.RecyclerView; import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.ViewGroup; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.databinding.MemberListItemBinding; import ca.rmen.android.scrumchatter.member.list.Members.Member; import ca.rmen.android.scrumchatter.provider.MemberCursorWrapper; import ca.rmen.android.scrumchatter.widget.ScrumChatterCursorAdapter;
/* * Copyright 2013-2016 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.member.list; /** * Adapter for the list of team members. */ public class MembersCursorAdapter extends ScrumChatterCursorAdapter<MembersCursorAdapter.MemberViewHolder> { private final MemberListener mMemberListener; MembersCursorAdapter(MemberListener memberListener) { super(); mMemberListener = memberListener; } public interface MemberListener {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/member/list/Members.java // public static class Member { // private final long id; // private final String name; // // Member(long memberId, String memberName) { // this.id = memberId; // this.name = memberName; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MemberCursorWrapper.java // public class MemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public Long getId() { // Integer index = getColumnIndex(MemberColumns._ID); // if (isNull(index)) return null; // return getLong(index); // } // // public String getName() { // Integer index = getIndex(MemberColumns.NAME); // return getString(index); // } // // public Integer getAverageDuration() { // Integer index = getIndex(MemberStatsColumns.AVG_DURATION); // return getInt(index); // } // // public Integer getSumDuration() { // Integer index = getIndex(MemberStatsColumns.SUM_DURATION); // return getInt(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/widget/ScrumChatterCursorAdapter.java // public abstract class ScrumChatterCursorAdapter<T extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<T> { // // private Cursor mCursor; // // protected ScrumChatterCursorAdapter() { // setHasStableIds(true); // } // public void changeCursor(Cursor cursor) { // if (mCursor == cursor) return; // mCursor = cursor; // notifyDataSetChanged(); // } // // @Override // public long getItemId(int position) { // if (mCursor == null || !mCursor.moveToPosition(position)) { // return RecyclerView.NO_ID; // } // return mCursor.getLong(mCursor.getColumnIndex(BaseColumns._ID)); // } // // @Override // public int getItemCount() { // if (mCursor == null) return 0; // else return mCursor.getCount(); // } // // protected Cursor getCursor() { // return mCursor; // } // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/member/list/MembersCursorAdapter.java import android.databinding.DataBindingUtil; import android.support.v7.widget.RecyclerView; import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.ViewGroup; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.databinding.MemberListItemBinding; import ca.rmen.android.scrumchatter.member.list.Members.Member; import ca.rmen.android.scrumchatter.provider.MemberCursorWrapper; import ca.rmen.android.scrumchatter.widget.ScrumChatterCursorAdapter; /* * Copyright 2013-2016 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.member.list; /** * Adapter for the list of team members. */ public class MembersCursorAdapter extends ScrumChatterCursorAdapter<MembersCursorAdapter.MemberViewHolder> { private final MemberListener mMemberListener; MembersCursorAdapter(MemberListener memberListener) { super(); mMemberListener = memberListener; } public interface MemberListener {
void onMemberEdit(Member member);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/member/list/MembersCursorAdapter.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/member/list/Members.java // public static class Member { // private final long id; // private final String name; // // Member(long memberId, String memberName) { // this.id = memberId; // this.name = memberName; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MemberCursorWrapper.java // public class MemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public Long getId() { // Integer index = getColumnIndex(MemberColumns._ID); // if (isNull(index)) return null; // return getLong(index); // } // // public String getName() { // Integer index = getIndex(MemberColumns.NAME); // return getString(index); // } // // public Integer getAverageDuration() { // Integer index = getIndex(MemberStatsColumns.AVG_DURATION); // return getInt(index); // } // // public Integer getSumDuration() { // Integer index = getIndex(MemberStatsColumns.SUM_DURATION); // return getInt(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/widget/ScrumChatterCursorAdapter.java // public abstract class ScrumChatterCursorAdapter<T extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<T> { // // private Cursor mCursor; // // protected ScrumChatterCursorAdapter() { // setHasStableIds(true); // } // public void changeCursor(Cursor cursor) { // if (mCursor == cursor) return; // mCursor = cursor; // notifyDataSetChanged(); // } // // @Override // public long getItemId(int position) { // if (mCursor == null || !mCursor.moveToPosition(position)) { // return RecyclerView.NO_ID; // } // return mCursor.getLong(mCursor.getColumnIndex(BaseColumns._ID)); // } // // @Override // public int getItemCount() { // if (mCursor == null) return 0; // else return mCursor.getCount(); // } // // protected Cursor getCursor() { // return mCursor; // } // }
import android.databinding.DataBindingUtil; import android.support.v7.widget.RecyclerView; import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.ViewGroup; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.databinding.MemberListItemBinding; import ca.rmen.android.scrumchatter.member.list.Members.Member; import ca.rmen.android.scrumchatter.provider.MemberCursorWrapper; import ca.rmen.android.scrumchatter.widget.ScrumChatterCursorAdapter;
/* * Copyright 2013-2016 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.member.list; /** * Adapter for the list of team members. */ public class MembersCursorAdapter extends ScrumChatterCursorAdapter<MembersCursorAdapter.MemberViewHolder> { private final MemberListener mMemberListener; MembersCursorAdapter(MemberListener memberListener) { super(); mMemberListener = memberListener; } public interface MemberListener { void onMemberEdit(Member member); void onMemberDelete(Member member); } @Override public MemberViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { MemberListItemBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.member_list_item, parent, false); binding.getRoot().setTag(binding); binding.setMemberListener(mMemberListener); return new MemberViewHolder(binding); } /** * Set up the view with the data from the given team member */ @Override public void onBindViewHolder(MemberViewHolder holder, int position) { // Get the data from the cursor @SuppressWarnings("resource")
// Path: app/src/main/java/ca/rmen/android/scrumchatter/member/list/Members.java // public static class Member { // private final long id; // private final String name; // // Member(long memberId, String memberName) { // this.id = memberId; // this.name = memberName; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MemberCursorWrapper.java // public class MemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public Long getId() { // Integer index = getColumnIndex(MemberColumns._ID); // if (isNull(index)) return null; // return getLong(index); // } // // public String getName() { // Integer index = getIndex(MemberColumns.NAME); // return getString(index); // } // // public Integer getAverageDuration() { // Integer index = getIndex(MemberStatsColumns.AVG_DURATION); // return getInt(index); // } // // public Integer getSumDuration() { // Integer index = getIndex(MemberStatsColumns.SUM_DURATION); // return getInt(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/widget/ScrumChatterCursorAdapter.java // public abstract class ScrumChatterCursorAdapter<T extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<T> { // // private Cursor mCursor; // // protected ScrumChatterCursorAdapter() { // setHasStableIds(true); // } // public void changeCursor(Cursor cursor) { // if (mCursor == cursor) return; // mCursor = cursor; // notifyDataSetChanged(); // } // // @Override // public long getItemId(int position) { // if (mCursor == null || !mCursor.moveToPosition(position)) { // return RecyclerView.NO_ID; // } // return mCursor.getLong(mCursor.getColumnIndex(BaseColumns._ID)); // } // // @Override // public int getItemCount() { // if (mCursor == null) return 0; // else return mCursor.getCount(); // } // // protected Cursor getCursor() { // return mCursor; // } // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/member/list/MembersCursorAdapter.java import android.databinding.DataBindingUtil; import android.support.v7.widget.RecyclerView; import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.ViewGroup; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.databinding.MemberListItemBinding; import ca.rmen.android.scrumchatter.member.list.Members.Member; import ca.rmen.android.scrumchatter.provider.MemberCursorWrapper; import ca.rmen.android.scrumchatter.widget.ScrumChatterCursorAdapter; /* * Copyright 2013-2016 Carmen Alvarez * * This file is part of Scrum Chatter. * * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.member.list; /** * Adapter for the list of team members. */ public class MembersCursorAdapter extends ScrumChatterCursorAdapter<MembersCursorAdapter.MemberViewHolder> { private final MemberListener mMemberListener; MembersCursorAdapter(MemberListener memberListener) { super(); mMemberListener = memberListener; } public interface MemberListener { void onMemberEdit(Member member); void onMemberDelete(Member member); } @Override public MemberViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { MemberListItemBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.member_list_item, parent, false); binding.getRoot().setTag(binding); binding.setMemberListener(mMemberListener); return new MemberViewHolder(binding); } /** * Set up the view with the data from the given team member */ @Override public void onBindViewHolder(MemberViewHolder holder, int position) { // Get the data from the cursor @SuppressWarnings("resource")
MemberCursorWrapper memberCursorWrapper = new MemberCursorWrapper(getCursor());
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/chart/ChartExportTask.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/export/BitmapExport.java // public class BitmapExport { // private static final String TAG = Constants.TAG + "/" + BitmapExport.class.getSimpleName(); // // private static final String FILE = "scrumchatter.png"; // private static final String MIME_TYPE = "image/png"; // private final Context mContext; // private final Bitmap mBitmap; // // public BitmapExport(Context context, Bitmap bitmap) { // mBitmap = bitmap; // mContext = context; // } // // /** // * Create and return a bitmap of our view. // * // * @see FileExport#createFile() // */ // private File createFile() { // Log.v(TAG, "export"); // // File file = Export.getExportFile(mContext, FILE); // if (file == null) return null; // // Draw everything to a bitmap. // FileOutputStream os = null; // try { // os = new FileOutputStream(file); // mBitmap.compress(Bitmap.CompressFormat.PNG, 100, os); // } catch (FileNotFoundException e) { // Log.v(TAG, "Error writing bitmap file", e); // } finally { // if (os != null) { // try { // os.close(); // } catch (IOException e) { // Log.v(TAG, "Error closing bitmap file", e); // } // } // } // // return file; // } // // /** // * Export the file. // */ // public void export() { // Log.v(TAG, "export"); // File file = createFile(); // Log.v(TAG, "export: created file " + file); // if (file != null && file.exists()) Export.share(mContext, file, MIME_TYPE); // } // // }
import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.support.annotation.MainThread; import android.support.design.widget.Snackbar; import android.view.View; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.export.BitmapExport; import io.reactivex.schedulers.Schedulers;
/* * Copyright 2016-2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; class ChartExportTask { private ChartExportTask() { // prevent instantiation } @MainThread static void export(Context context, View view) { Snackbar.make(view, context.getString(R.string.chart_exporting_snackbar), Snackbar.LENGTH_LONG).show(); Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); view.draw(canvas); Schedulers.io().scheduleDirect(() -> {
// Path: app/src/main/java/ca/rmen/android/scrumchatter/export/BitmapExport.java // public class BitmapExport { // private static final String TAG = Constants.TAG + "/" + BitmapExport.class.getSimpleName(); // // private static final String FILE = "scrumchatter.png"; // private static final String MIME_TYPE = "image/png"; // private final Context mContext; // private final Bitmap mBitmap; // // public BitmapExport(Context context, Bitmap bitmap) { // mBitmap = bitmap; // mContext = context; // } // // /** // * Create and return a bitmap of our view. // * // * @see FileExport#createFile() // */ // private File createFile() { // Log.v(TAG, "export"); // // File file = Export.getExportFile(mContext, FILE); // if (file == null) return null; // // Draw everything to a bitmap. // FileOutputStream os = null; // try { // os = new FileOutputStream(file); // mBitmap.compress(Bitmap.CompressFormat.PNG, 100, os); // } catch (FileNotFoundException e) { // Log.v(TAG, "Error writing bitmap file", e); // } finally { // if (os != null) { // try { // os.close(); // } catch (IOException e) { // Log.v(TAG, "Error closing bitmap file", e); // } // } // } // // return file; // } // // /** // * Export the file. // */ // public void export() { // Log.v(TAG, "export"); // File file = createFile(); // Log.v(TAG, "export: created file " + file); // if (file != null && file.exists()) Export.share(mContext, file, MIME_TYPE); // } // // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/chart/ChartExportTask.java import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.support.annotation.MainThread; import android.support.design.widget.Snackbar; import android.view.View; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.export.BitmapExport; import io.reactivex.schedulers.Schedulers; /* * Copyright 2016-2017 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; class ChartExportTask { private ChartExportTask() { // prevent instantiation } @MainThread static void export(Context context, View view) { Snackbar.make(view, context.getString(R.string.chart_exporting_snackbar), Snackbar.LENGTH_LONG).show(); Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); view.draw(canvas); Schedulers.io().scheduleDirect(() -> {
BitmapExport export = new BitmapExport(context, bitmap);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/chart/MemberSpeakingTimeColumnChart.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MeetingMemberCursorWrapper.java // public class MeetingMemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MeetingMemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public long getMeetingId() { // return getLongField(MeetingMemberColumns.MEETING_ID); // } // // public long getMemberId() { // return getLongField(MeetingMemberColumns.MEMBER_ID); // } // // public String getMemberName() { // Integer index = getIndex(MemberColumns.NAME); // if (isNull(index)) return null; // return getString(index); // } // // public long getDuration() { // return getLongField(MeetingMemberColumns.DURATION); // } // // public long getTotalDuration() { // return getLongField(MeetingColumns.TOTAL_DURATION); // } // // public long getTalkStartTime() { // return getLongField(MeetingMemberColumns.TALK_START_TIME); // } // // public long getMeetingDate() { // return getLongField(MeetingColumns.MEETING_DATE); // } // // public State getMeetingState() { // Integer index = getIndex(MeetingColumns.STATE); // if (isNull(index)) return State.NOT_STARTED; // int stateInt = getInt(index); // return State.values()[stateInt]; // } // // private long getLongField(String columnName) { // Integer index = getIndex(columnName); // if (isNull(index)) return 0; // return getLong(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/TextUtils.java // public class TextUtils { // public static String formatDateTime(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); // } // // public static String formatDate(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL |DateUtils.FORMAT_NUMERIC_DATE); // } // // }
import android.content.Context; import android.database.Cursor; import android.support.annotation.NonNull; import android.text.format.DateUtils; import android.util.DisplayMetrics; import android.view.ViewGroup; import android.view.WindowManager; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.provider.MeetingMemberCursorWrapper; import ca.rmen.android.scrumchatter.util.TextUtils; import lecho.lib.hellocharts.gesture.ZoomType; import lecho.lib.hellocharts.model.Axis; import lecho.lib.hellocharts.model.AxisValue; import lecho.lib.hellocharts.model.Column; import lecho.lib.hellocharts.model.ColumnChartData; import lecho.lib.hellocharts.model.SubcolumnValue; import lecho.lib.hellocharts.view.ColumnChartView;
/* * Copyright 2016 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; /** * The member speaking-time chart has one stacked column per meeting, with each column having stacked * boxes for each member (the time the member spoke during that meeting). */ final class MemberSpeakingTimeColumnChart { private MemberSpeakingTimeColumnChart() { // prevent instantiation } static void populateMemberSpeakingTimeChart(Context context, ColumnChartView chart, ViewGroup legendView, @NonNull Cursor cursor) { List<AxisValue> xAxisValues = new ArrayList<>(); List<Column> columns = new ArrayList<>();
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MeetingMemberCursorWrapper.java // public class MeetingMemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MeetingMemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public long getMeetingId() { // return getLongField(MeetingMemberColumns.MEETING_ID); // } // // public long getMemberId() { // return getLongField(MeetingMemberColumns.MEMBER_ID); // } // // public String getMemberName() { // Integer index = getIndex(MemberColumns.NAME); // if (isNull(index)) return null; // return getString(index); // } // // public long getDuration() { // return getLongField(MeetingMemberColumns.DURATION); // } // // public long getTotalDuration() { // return getLongField(MeetingColumns.TOTAL_DURATION); // } // // public long getTalkStartTime() { // return getLongField(MeetingMemberColumns.TALK_START_TIME); // } // // public long getMeetingDate() { // return getLongField(MeetingColumns.MEETING_DATE); // } // // public State getMeetingState() { // Integer index = getIndex(MeetingColumns.STATE); // if (isNull(index)) return State.NOT_STARTED; // int stateInt = getInt(index); // return State.values()[stateInt]; // } // // private long getLongField(String columnName) { // Integer index = getIndex(columnName); // if (isNull(index)) return 0; // return getLong(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/TextUtils.java // public class TextUtils { // public static String formatDateTime(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); // } // // public static String formatDate(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL |DateUtils.FORMAT_NUMERIC_DATE); // } // // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/chart/MemberSpeakingTimeColumnChart.java import android.content.Context; import android.database.Cursor; import android.support.annotation.NonNull; import android.text.format.DateUtils; import android.util.DisplayMetrics; import android.view.ViewGroup; import android.view.WindowManager; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.provider.MeetingMemberCursorWrapper; import ca.rmen.android.scrumchatter.util.TextUtils; import lecho.lib.hellocharts.gesture.ZoomType; import lecho.lib.hellocharts.model.Axis; import lecho.lib.hellocharts.model.AxisValue; import lecho.lib.hellocharts.model.Column; import lecho.lib.hellocharts.model.ColumnChartData; import lecho.lib.hellocharts.model.SubcolumnValue; import lecho.lib.hellocharts.view.ColumnChartView; /* * Copyright 2016 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; /** * The member speaking-time chart has one stacked column per meeting, with each column having stacked * boxes for each member (the time the member spoke during that meeting). */ final class MemberSpeakingTimeColumnChart { private MemberSpeakingTimeColumnChart() { // prevent instantiation } static void populateMemberSpeakingTimeChart(Context context, ColumnChartView chart, ViewGroup legendView, @NonNull Cursor cursor) { List<AxisValue> xAxisValues = new ArrayList<>(); List<Column> columns = new ArrayList<>();
MeetingMemberCursorWrapper cursorWrapper = new MeetingMemberCursorWrapper(cursor);
caarmen/scrumchatter
app/src/main/java/ca/rmen/android/scrumchatter/chart/MemberSpeakingTimeColumnChart.java
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MeetingMemberCursorWrapper.java // public class MeetingMemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MeetingMemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public long getMeetingId() { // return getLongField(MeetingMemberColumns.MEETING_ID); // } // // public long getMemberId() { // return getLongField(MeetingMemberColumns.MEMBER_ID); // } // // public String getMemberName() { // Integer index = getIndex(MemberColumns.NAME); // if (isNull(index)) return null; // return getString(index); // } // // public long getDuration() { // return getLongField(MeetingMemberColumns.DURATION); // } // // public long getTotalDuration() { // return getLongField(MeetingColumns.TOTAL_DURATION); // } // // public long getTalkStartTime() { // return getLongField(MeetingMemberColumns.TALK_START_TIME); // } // // public long getMeetingDate() { // return getLongField(MeetingColumns.MEETING_DATE); // } // // public State getMeetingState() { // Integer index = getIndex(MeetingColumns.STATE); // if (isNull(index)) return State.NOT_STARTED; // int stateInt = getInt(index); // return State.values()[stateInt]; // } // // private long getLongField(String columnName) { // Integer index = getIndex(columnName); // if (isNull(index)) return 0; // return getLong(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/TextUtils.java // public class TextUtils { // public static String formatDateTime(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); // } // // public static String formatDate(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL |DateUtils.FORMAT_NUMERIC_DATE); // } // // }
import android.content.Context; import android.database.Cursor; import android.support.annotation.NonNull; import android.text.format.DateUtils; import android.util.DisplayMetrics; import android.view.ViewGroup; import android.view.WindowManager; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.provider.MeetingMemberCursorWrapper; import ca.rmen.android.scrumchatter.util.TextUtils; import lecho.lib.hellocharts.gesture.ZoomType; import lecho.lib.hellocharts.model.Axis; import lecho.lib.hellocharts.model.AxisValue; import lecho.lib.hellocharts.model.Column; import lecho.lib.hellocharts.model.ColumnChartData; import lecho.lib.hellocharts.model.SubcolumnValue; import lecho.lib.hellocharts.view.ColumnChartView;
/* * Copyright 2016 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; /** * The member speaking-time chart has one stacked column per meeting, with each column having stacked * boxes for each member (the time the member spoke during that meeting). */ final class MemberSpeakingTimeColumnChart { private MemberSpeakingTimeColumnChart() { // prevent instantiation } static void populateMemberSpeakingTimeChart(Context context, ColumnChartView chart, ViewGroup legendView, @NonNull Cursor cursor) { List<AxisValue> xAxisValues = new ArrayList<>(); List<Column> columns = new ArrayList<>(); MeetingMemberCursorWrapper cursorWrapper = new MeetingMemberCursorWrapper(cursor); Map<String, Integer> memberColors = new TreeMap<>(); long lastMeetingId = -1; List<SubcolumnValue> subcolumnValues = new ArrayList<>(); while (cursorWrapper.moveToNext()) { do { long currentMeetingId = cursorWrapper.getMeetingId(); if (currentMeetingId != lastMeetingId) { if (!subcolumnValues.isEmpty()) { Column column = new Column(subcolumnValues); column.setHasLabelsOnlyForSelected(true); columns.add(column); AxisValue xAxisValue = new AxisValue(xAxisValues.size());
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MeetingMemberCursorWrapper.java // public class MeetingMemberCursorWrapper extends CursorWrapper { // private final HashMap<String, Integer> mColumnIndexes = new HashMap<>(); // // public MeetingMemberCursorWrapper(Cursor cursor) { // super(cursor); // } // // public long getMeetingId() { // return getLongField(MeetingMemberColumns.MEETING_ID); // } // // public long getMemberId() { // return getLongField(MeetingMemberColumns.MEMBER_ID); // } // // public String getMemberName() { // Integer index = getIndex(MemberColumns.NAME); // if (isNull(index)) return null; // return getString(index); // } // // public long getDuration() { // return getLongField(MeetingMemberColumns.DURATION); // } // // public long getTotalDuration() { // return getLongField(MeetingColumns.TOTAL_DURATION); // } // // public long getTalkStartTime() { // return getLongField(MeetingMemberColumns.TALK_START_TIME); // } // // public long getMeetingDate() { // return getLongField(MeetingColumns.MEETING_DATE); // } // // public State getMeetingState() { // Integer index = getIndex(MeetingColumns.STATE); // if (isNull(index)) return State.NOT_STARTED; // int stateInt = getInt(index); // return State.values()[stateInt]; // } // // private long getLongField(String columnName) { // Integer index = getIndex(columnName); // if (isNull(index)) return 0; // return getLong(index); // } // // private Integer getIndex(String columnName) { // Integer index = mColumnIndexes.get(columnName); // if (index == null) { // index = getColumnIndexOrThrow(columnName); // mColumnIndexes.put(columnName, index); // } // return index; // } // } // // Path: app/src/main/java/ca/rmen/android/scrumchatter/util/TextUtils.java // public class TextUtils { // public static String formatDateTime(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); // } // // public static String formatDate(Context context, long dateMillis) { // return DateUtils.formatDateTime(context, dateMillis, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL |DateUtils.FORMAT_NUMERIC_DATE); // } // // } // Path: app/src/main/java/ca/rmen/android/scrumchatter/chart/MemberSpeakingTimeColumnChart.java import android.content.Context; import android.database.Cursor; import android.support.annotation.NonNull; import android.text.format.DateUtils; import android.util.DisplayMetrics; import android.view.ViewGroup; import android.view.WindowManager; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; import ca.rmen.android.scrumchatter.R; import ca.rmen.android.scrumchatter.provider.MeetingMemberCursorWrapper; import ca.rmen.android.scrumchatter.util.TextUtils; import lecho.lib.hellocharts.gesture.ZoomType; import lecho.lib.hellocharts.model.Axis; import lecho.lib.hellocharts.model.AxisValue; import lecho.lib.hellocharts.model.Column; import lecho.lib.hellocharts.model.ColumnChartData; import lecho.lib.hellocharts.model.SubcolumnValue; import lecho.lib.hellocharts.view.ColumnChartView; /* * Copyright 2016 Carmen Alvarez * <p/> * This file is part of Scrum Chatter. * <p/> * Scrum Chatter is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p/> * Scrum Chatter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>. */ package ca.rmen.android.scrumchatter.chart; /** * The member speaking-time chart has one stacked column per meeting, with each column having stacked * boxes for each member (the time the member spoke during that meeting). */ final class MemberSpeakingTimeColumnChart { private MemberSpeakingTimeColumnChart() { // prevent instantiation } static void populateMemberSpeakingTimeChart(Context context, ColumnChartView chart, ViewGroup legendView, @NonNull Cursor cursor) { List<AxisValue> xAxisValues = new ArrayList<>(); List<Column> columns = new ArrayList<>(); MeetingMemberCursorWrapper cursorWrapper = new MeetingMemberCursorWrapper(cursor); Map<String, Integer> memberColors = new TreeMap<>(); long lastMeetingId = -1; List<SubcolumnValue> subcolumnValues = new ArrayList<>(); while (cursorWrapper.moveToNext()) { do { long currentMeetingId = cursorWrapper.getMeetingId(); if (currentMeetingId != lastMeetingId) { if (!subcolumnValues.isEmpty()) { Column column = new Column(subcolumnValues); column.setHasLabelsOnlyForSelected(true); columns.add(column); AxisValue xAxisValue = new AxisValue(xAxisValues.size());
String dateString = TextUtils.formatDate(context, cursorWrapper.getMeetingDate());
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/BudgetRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class BudgetRepositoryTest { @Autowired private BudgetRepository testSubject; @Autowired
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/BudgetRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class BudgetRepositoryTest { @Autowired private BudgetRepository testSubject; @Autowired
private UserRepository userRepository;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/BudgetRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class BudgetRepositoryTest { @Autowired private BudgetRepository testSubject; @Autowired private UserRepository userRepository; @Test public void shouldSaveNewMaterCategories() {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/BudgetRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class BudgetRepositoryTest { @Autowired private BudgetRepository testSubject; @Autowired private UserRepository userRepository; @Test public void shouldSaveNewMaterCategories() {
User user = userRepository.save(new User().setName("Bob").setCurrency("€"));
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/MasterCategoryRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class MasterCategoryRepositoryTest { @Autowired private MasterCategoryRepository testSubject; @Autowired
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/MasterCategoryRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class MasterCategoryRepositoryTest { @Autowired private MasterCategoryRepository testSubject; @Autowired
private UserRepository userRepository;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/MasterCategoryRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class MasterCategoryRepositoryTest { @Autowired private MasterCategoryRepository testSubject; @Autowired private UserRepository userRepository; @Test public void shouldSaveNewMaterCategories() {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/MasterCategoryRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class MasterCategoryRepositoryTest { @Autowired private MasterCategoryRepository testSubject; @Autowired private UserRepository userRepository; @Test public void shouldSaveNewMaterCategories() {
User user = userRepository.save(new User().setName("Bob").setCurrency("€"));
BudgetFreak/BudgetFreak
server/budgeting/src/main/java/de/budgetfreak/budgeting/service/BudgetService.java
// Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long>, JpaSpecificationExecutor<Category> { // }
import de.budgetfreak.budgeting.domain.CategoryRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
package de.budgetfreak.budgeting.service; /** * Service for managing budgets. */ @Service public class BudgetService {
// Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long>, JpaSpecificationExecutor<Category> { // } // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/service/BudgetService.java import de.budgetfreak.budgeting.domain.CategoryRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; package de.budgetfreak.budgeting.service; /** * Service for managing budgets. */ @Service public class BudgetService {
private CategoryRepository categoryRepository;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/TransactionRepositoryTest.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Date; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class TransactionRepositoryTest { @Autowired private TransactionRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/TransactionRepositoryTest.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Date; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class TransactionRepositoryTest { @Autowired private TransactionRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired
private UserRepository userRepository;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/TransactionRepositoryTest.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Date; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class TransactionRepositoryTest { @Autowired private TransactionRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired private UserRepository userRepository; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired private PayeeRepository payeeRepository; @Autowired
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/TransactionRepositoryTest.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Date; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class TransactionRepositoryTest { @Autowired private TransactionRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired private UserRepository userRepository; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired private PayeeRepository payeeRepository; @Autowired
private AccountRepository accountRepository;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/TransactionRepositoryTest.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Date; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class TransactionRepositoryTest { @Autowired private TransactionRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired private UserRepository userRepository; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired private PayeeRepository payeeRepository; @Autowired private AccountRepository accountRepository; @Test public void shouldSaveNewMaterCategories() {
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/TransactionRepositoryTest.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Date; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class TransactionRepositoryTest { @Autowired private TransactionRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired private UserRepository userRepository; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired private PayeeRepository payeeRepository; @Autowired private AccountRepository accountRepository; @Test public void shouldSaveNewMaterCategories() {
User user = userRepository.save(new User().setName("Bob").setCurrency("€"));
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/TransactionRepositoryTest.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Date; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class TransactionRepositoryTest { @Autowired private TransactionRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired private UserRepository userRepository; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired private PayeeRepository payeeRepository; @Autowired private AccountRepository accountRepository; @Test public void shouldSaveNewMaterCategories() { User user = userRepository.save(new User().setName("Bob").setCurrency("€")); MasterCategory masterCategory = masterCategoryRepository.save(new MasterCategory().setName("mastercategory").setUser(user)); Category category = categoryRepository.save(new Category().setName("category").setMasterCategory(masterCategory)); Payee payee = payeeRepository.save(new Payee().setName("payee").setUser(user));
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/TransactionRepositoryTest.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Date; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class TransactionRepositoryTest { @Autowired private TransactionRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired private UserRepository userRepository; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired private PayeeRepository payeeRepository; @Autowired private AccountRepository accountRepository; @Test public void shouldSaveNewMaterCategories() { User user = userRepository.save(new User().setName("Bob").setCurrency("€")); MasterCategory masterCategory = masterCategoryRepository.save(new MasterCategory().setName("mastercategory").setUser(user)); Category category = categoryRepository.save(new Category().setName("category").setMasterCategory(masterCategory)); Payee payee = payeeRepository.save(new Payee().setName("payee").setUser(user));
Account account = accountRepository.save(new Account().setUser(user).setOnBudget(true).setDescription("account"));
BudgetFreak/BudgetFreak
server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Budget.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import de.budgetfreak.usermanagement.domain.User; import javax.persistence.*;
package de.budgetfreak.budgeting.domain; /** * A budget is planned for a specific month. It consists of a {@link CategoryBudget} for every * {@link Category}. */ @Entity(name = "BF_BUDGET") public class Budget { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "YEAR") private int year; @Column(name = "MONTH") private int month; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "USER_ID")
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Budget.java import de.budgetfreak.usermanagement.domain.User; import javax.persistence.*; package de.budgetfreak.budgeting.domain; /** * A budget is planned for a specific month. It consists of a {@link CategoryBudget} for every * {@link Category}. */ @Entity(name = "BF_BUDGET") public class Budget { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "YEAR") private int year; @Column(name = "MONTH") private int month; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "USER_ID")
private User user;
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import de.budgetfreak.usermanagement.domain.User; import java.util.Arrays; import java.util.List;
package de.budgetfreak.accounting; public class UserTestUtils { private UserTestUtils() { }
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java import de.budgetfreak.usermanagement.domain.User; import java.util.Arrays; import java.util.List; package de.budgetfreak.accounting; public class UserTestUtils { private UserTestUtils() { }
public static List<User> createBobAndJane() {
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/domain/AccountRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit4.SpringRunner; import javax.persistence.Entity; import java.util.List; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.accounting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @Sql(value = "accounts.sql") @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class AccountRepositoryTest { @Autowired private AccountRepository testSubject; @Autowired
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/domain/AccountRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit4.SpringRunner; import javax.persistence.Entity; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.accounting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @Sql(value = "accounts.sql") @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class AccountRepositoryTest { @Autowired private AccountRepository testSubject; @Autowired
private UserRepository userRepository;
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/domain/AccountRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit4.SpringRunner; import javax.persistence.Entity; import java.util.List; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.accounting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @Sql(value = "accounts.sql") @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class AccountRepositoryTest { @Autowired private AccountRepository testSubject; @Autowired private UserRepository userRepository; @Test public void shouldBeInitialized() { assertThat(testSubject).isNotNull(); } @Test public void shouldNotBeEmpty() { assertThat(testSubject.count()).isEqualTo(3); } @Test public void maxShouldHaveTwoAccounts() {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/domain/AccountRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit4.SpringRunner; import javax.persistence.Entity; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.accounting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @Sql(value = "accounts.sql") @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class AccountRepositoryTest { @Autowired private AccountRepository testSubject; @Autowired private UserRepository userRepository; @Test public void shouldBeInitialized() { assertThat(testSubject).isNotNull(); } @Test public void shouldNotBeEmpty() { assertThat(testSubject.count()).isEqualTo(3); } @Test public void maxShouldHaveTwoAccounts() {
User max = userRepository.findByName("Max");
BudgetFreak/BudgetFreak
server/user-management/src/test/java/de/budgetfreak/usermanagement/web/UserResourceAssemblerTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.springframework.test.context.junit4.SpringRunner; import de.budgetfreak.usermanagement.domain.User;
package de.budgetfreak.usermanagement.web; @RunWith(SpringRunner.class) public class UserResourceAssemblerTest { private static final String NAME = "Geralt of Rivia"; private static final String CURRENCY = "?"; @InjectMocks private UserResourceAssembler testSubject; @Test public void createResource() throws Exception {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/web/UserResourceAssemblerTest.java import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.springframework.test.context.junit4.SpringRunner; import de.budgetfreak.usermanagement.domain.User; package de.budgetfreak.usermanagement.web; @RunWith(SpringRunner.class) public class UserResourceAssemblerTest { private static final String NAME = "Geralt of Rivia"; private static final String CURRENCY = "?"; @InjectMocks private UserResourceAssembler testSubject; @Test public void createResource() throws Exception {
UserResource userResource = testSubject.createResource(new User(NAME, CURRENCY));
BudgetFreak/BudgetFreak
server/user-management/src/test/java/de/budgetfreak/usermanagement/UserServiceIntegrationTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/service/UserService.java // @Service // @EnableConfigurationProperties(UserManagementProperties.class) // public class UserService { // // private UserRepository userRepository; // private UserManagementProperties userManagementProperties; // // @Autowired // public UserService(UserRepository userRepository, UserManagementProperties userManagementProperties) { // this.userRepository = userRepository; // this.userManagementProperties = userManagementProperties; // } // // /** // * List all users in no given order. // */ // public List<User> list() { // return userRepository.findAll(); // } // // /** // * Create and saves an user. // * // * @return The created entity. // */ // public User create(String name, String currency) { // final User user = new User(name, currency); // return userRepository.save(user); // } // // /** // * Get one user by id. // */ // public User get(long id) { // return userRepository.findOne(Example.of(new User().setId(id))).orElse(null); // } // // /** // * Reads the testProperty. // * // * @return The configured property. // */ // public String getTestProperty() { // return userManagementProperties.getTestProperty(); // } // }
import de.budgetfreak.usermanagement.service.UserService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.usermanagement; @RunWith(SpringRunner.class) @SpringBootTest public class UserServiceIntegrationTest { @Autowired
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/service/UserService.java // @Service // @EnableConfigurationProperties(UserManagementProperties.class) // public class UserService { // // private UserRepository userRepository; // private UserManagementProperties userManagementProperties; // // @Autowired // public UserService(UserRepository userRepository, UserManagementProperties userManagementProperties) { // this.userRepository = userRepository; // this.userManagementProperties = userManagementProperties; // } // // /** // * List all users in no given order. // */ // public List<User> list() { // return userRepository.findAll(); // } // // /** // * Create and saves an user. // * // * @return The created entity. // */ // public User create(String name, String currency) { // final User user = new User(name, currency); // return userRepository.save(user); // } // // /** // * Get one user by id. // */ // public User get(long id) { // return userRepository.findOne(Example.of(new User().setId(id))).orElse(null); // } // // /** // * Reads the testProperty. // * // * @return The configured property. // */ // public String getTestProperty() { // return userManagementProperties.getTestProperty(); // } // } // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/UserServiceIntegrationTest.java import de.budgetfreak.usermanagement.service.UserService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.usermanagement; @RunWith(SpringRunner.class) @SpringBootTest public class UserServiceIntegrationTest { @Autowired
private UserService testSubject;
BudgetFreak/BudgetFreak
server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Payee.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import de.budgetfreak.usermanagement.domain.User; import javax.persistence.*;
package de.budgetfreak.budgeting.domain; /** * A payee can be linked to {@link Transaction}-entities. */ @Entity(name = "BF_PAYEE") public class Payee { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "NAME") private String name; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "USER_ID")
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Payee.java import de.budgetfreak.usermanagement.domain.User; import javax.persistence.*; package de.budgetfreak.budgeting.domain; /** * A payee can be linked to {@link Transaction}-entities. */ @Entity(name = "BF_PAYEE") public class Payee { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "NAME") private String name; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "USER_ID")
private User user;
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*;
package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject;
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject;
private AccountRepository accountRepositoryMock;
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*;
package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject; private AccountRepository accountRepositoryMock;
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject; private AccountRepository accountRepositoryMock;
private UserRepository userRepositoryMock;
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*;
package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject; private AccountRepository accountRepositoryMock; private UserRepository userRepositoryMock; @Before public void setUp() { accountRepositoryMock = mock(AccountRepository.class); userRepositoryMock = mock(UserRepository.class); testSubject = new AccountService(accountRepositoryMock, userRepositoryMock); } @Test public void shouldListAccounts() {
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject; private AccountRepository accountRepositoryMock; private UserRepository userRepositoryMock; @Before public void setUp() { accountRepositoryMock = mock(AccountRepository.class); userRepositoryMock = mock(UserRepository.class); testSubject = new AccountService(accountRepositoryMock, userRepositoryMock); } @Test public void shouldListAccounts() {
User bob = UserTestUtils.createBob();
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*;
package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject; private AccountRepository accountRepositoryMock; private UserRepository userRepositoryMock; @Before public void setUp() { accountRepositoryMock = mock(AccountRepository.class); userRepositoryMock = mock(UserRepository.class); testSubject = new AccountService(accountRepositoryMock, userRepositoryMock); } @Test public void shouldListAccounts() {
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject; private AccountRepository accountRepositoryMock; private UserRepository userRepositoryMock; @Before public void setUp() { accountRepositoryMock = mock(AccountRepository.class); userRepositoryMock = mock(UserRepository.class); testSubject = new AccountService(accountRepositoryMock, userRepositoryMock); } @Test public void shouldListAccounts() {
User bob = UserTestUtils.createBob();
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*;
package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject; private AccountRepository accountRepositoryMock; private UserRepository userRepositoryMock; @Before public void setUp() { accountRepositoryMock = mock(AccountRepository.class); userRepositoryMock = mock(UserRepository.class); testSubject = new AccountService(accountRepositoryMock, userRepositoryMock); } @Test public void shouldListAccounts() { User bob = UserTestUtils.createBob();
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject; private AccountRepository accountRepositoryMock; private UserRepository userRepositoryMock; @Before public void setUp() { accountRepositoryMock = mock(AccountRepository.class); userRepositoryMock = mock(UserRepository.class); testSubject = new AccountService(accountRepositoryMock, userRepositoryMock); } @Test public void shouldListAccounts() { User bob = UserTestUtils.createBob();
Account checkings = AccountTestUtils.createCheckingsAccount(bob);
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*;
package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject; private AccountRepository accountRepositoryMock; private UserRepository userRepositoryMock; @Before public void setUp() { accountRepositoryMock = mock(AccountRepository.class); userRepositoryMock = mock(UserRepository.class); testSubject = new AccountService(accountRepositoryMock, userRepositoryMock); } @Test public void shouldListAccounts() { User bob = UserTestUtils.createBob();
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/service/AccountServiceTest.java import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; package de.budgetfreak.accounting.service; public class AccountServiceTest { private AccountService testSubject; private AccountRepository accountRepositoryMock; private UserRepository userRepositoryMock; @Before public void setUp() { accountRepositoryMock = mock(AccountRepository.class); userRepositoryMock = mock(UserRepository.class); testSubject = new AccountService(accountRepositoryMock, userRepositoryMock); } @Test public void shouldListAccounts() { User bob = UserTestUtils.createBob();
Account checkings = AccountTestUtils.createCheckingsAccount(bob);
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.usermanagement.domain.User; import java.util.List; import static java.util.Arrays.asList;
package de.budgetfreak.accounting; public class AccountTestUtils { private AccountTestUtils() { }
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.usermanagement.domain.User; import java.util.List; import static java.util.Arrays.asList; package de.budgetfreak.accounting; public class AccountTestUtils { private AccountTestUtils() { }
public static List<Account> createAccounts(User user) {
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.usermanagement.domain.User; import java.util.List; import static java.util.Arrays.asList;
package de.budgetfreak.accounting; public class AccountTestUtils { private AccountTestUtils() { }
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.usermanagement.domain.User; import java.util.List; import static java.util.Arrays.asList; package de.budgetfreak.accounting; public class AccountTestUtils { private AccountTestUtils() { }
public static List<Account> createAccounts(User user) {
BudgetFreak/BudgetFreak
server/accounting/src/main/java/de/budgetfreak/accounting/web/AccountResourceAssembler.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/web/UserController.java // @RestController // @RequestMapping("/users") // public class UserController { // // private UserService userService; // private UserResourceAssembler userResourceAssembler; // // @InitBinder // protected void initBinder(WebDataBinder binder) { // // TODO Maybe define global validators? // binder.setValidator(new UserResourceValidator()); // } // // // @Autowired // public UserController(UserService userService, UserResourceAssembler userResourceAssembler) { // this.userService = userService; // this.userResourceAssembler = userResourceAssembler; // } // // /** // * List all users in no given order. // */ // @GetMapping // public Resources<UserResource> list() { // List<User> users = userService.list(); // List<UserResource> resources = userResourceAssembler.toResources(users); // final Link selfRel = linkTo(methodOn(UserController.class).list()).withSelfRel(); // return new Resources<>(resources, selfRel); // } // // /** // * Get one user. // */ // @GetMapping("/{userId}") // public Resource<UserResource> get(@PathVariable("userId") long userId) { // User user = userService.get(userId); // final UserResource userResource = userResourceAssembler.toResource(user); // return new Resource<>(userResource); // } // // /** // * Create an user. // */ // @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE) // public ResponseEntity<UserResource> create(@RequestBody @Valid UserResource userResource) { // User user = userService.create(userResource.getName(), userResource.getCurrency()); // final UserResource createdUserResource = userResourceAssembler.toResource(user); // return new ResponseEntity<>(createdUserResource, HttpStatus.OK); // } // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.usermanagement.web.UserController; import org.springframework.hateoas.mvc.ResourceAssemblerSupport; import org.springframework.stereotype.Component; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
package de.budgetfreak.accounting.web; /** * Assembler for {@link AccountResource}. */ @Component public class AccountResourceAssembler extends ResourceAssemblerSupport<Account, AccountResource> { public AccountResourceAssembler() { super(AccountController.class, AccountResource.class); } @Override public AccountResource toResource(Account entity) { final AccountResource accountResource = new AccountResource(entity.getDescription(), entity.isOnBudget()); accountResource.add(linkTo(methodOn(AccountController.class).get(entity.getUser().getId(), entity.getId())).withSelfRel());
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/web/UserController.java // @RestController // @RequestMapping("/users") // public class UserController { // // private UserService userService; // private UserResourceAssembler userResourceAssembler; // // @InitBinder // protected void initBinder(WebDataBinder binder) { // // TODO Maybe define global validators? // binder.setValidator(new UserResourceValidator()); // } // // // @Autowired // public UserController(UserService userService, UserResourceAssembler userResourceAssembler) { // this.userService = userService; // this.userResourceAssembler = userResourceAssembler; // } // // /** // * List all users in no given order. // */ // @GetMapping // public Resources<UserResource> list() { // List<User> users = userService.list(); // List<UserResource> resources = userResourceAssembler.toResources(users); // final Link selfRel = linkTo(methodOn(UserController.class).list()).withSelfRel(); // return new Resources<>(resources, selfRel); // } // // /** // * Get one user. // */ // @GetMapping("/{userId}") // public Resource<UserResource> get(@PathVariable("userId") long userId) { // User user = userService.get(userId); // final UserResource userResource = userResourceAssembler.toResource(user); // return new Resource<>(userResource); // } // // /** // * Create an user. // */ // @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE) // public ResponseEntity<UserResource> create(@RequestBody @Valid UserResource userResource) { // User user = userService.create(userResource.getName(), userResource.getCurrency()); // final UserResource createdUserResource = userResourceAssembler.toResource(user); // return new ResponseEntity<>(createdUserResource, HttpStatus.OK); // } // } // Path: server/accounting/src/main/java/de/budgetfreak/accounting/web/AccountResourceAssembler.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.usermanagement.web.UserController; import org.springframework.hateoas.mvc.ResourceAssemblerSupport; import org.springframework.stereotype.Component; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; package de.budgetfreak.accounting.web; /** * Assembler for {@link AccountResource}. */ @Component public class AccountResourceAssembler extends ResourceAssemblerSupport<Account, AccountResource> { public AccountResourceAssembler() { super(AccountController.class, AccountResource.class); } @Override public AccountResource toResource(Account entity) { final AccountResource accountResource = new AccountResource(entity.getDescription(), entity.isOnBudget()); accountResource.add(linkTo(methodOn(AccountController.class).get(entity.getUser().getId(), entity.getId())).withSelfRel());
accountResource.add(linkTo(methodOn(UserController.class).get(entity.getUser().getId())).withRel("user"));
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/PayeeRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class PayeeRepositoryTest { @Autowired private PayeeRepository testSubject; @Autowired
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/PayeeRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class PayeeRepositoryTest { @Autowired private PayeeRepository testSubject; @Autowired
private UserRepository userRepository;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/PayeeRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class PayeeRepositoryTest { @Autowired private PayeeRepository testSubject; @Autowired private UserRepository userRepository; @Test public void shouldSaveNewMaterCategories() {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/PayeeRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class PayeeRepositoryTest { @Autowired private PayeeRepository testSubject; @Autowired private UserRepository userRepository; @Test public void shouldSaveNewMaterCategories() {
User user = userRepository.save(new User().setName("Bob").setCurrency("€"));
BudgetFreak/BudgetFreak
server/user-management/src/main/java/de/budgetfreak/usermanagement/service/UserService.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List;
package de.budgetfreak.usermanagement.service; /** * Service for managing users. */ @Service @EnableConfigurationProperties(UserManagementProperties.class) public class UserService {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/service/UserService.java import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List; package de.budgetfreak.usermanagement.service; /** * Service for managing users. */ @Service @EnableConfigurationProperties(UserManagementProperties.class) public class UserService {
private UserRepository userRepository;
BudgetFreak/BudgetFreak
server/user-management/src/main/java/de/budgetfreak/usermanagement/service/UserService.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List;
package de.budgetfreak.usermanagement.service; /** * Service for managing users. */ @Service @EnableConfigurationProperties(UserManagementProperties.class) public class UserService { private UserRepository userRepository; private UserManagementProperties userManagementProperties; @Autowired public UserService(UserRepository userRepository, UserManagementProperties userManagementProperties) { this.userRepository = userRepository; this.userManagementProperties = userManagementProperties; } /** * List all users in no given order. */
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/service/UserService.java import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List; package de.budgetfreak.usermanagement.service; /** * Service for managing users. */ @Service @EnableConfigurationProperties(UserManagementProperties.class) public class UserService { private UserRepository userRepository; private UserManagementProperties userManagementProperties; @Autowired public UserService(UserRepository userRepository, UserManagementProperties userManagementProperties) { this.userRepository = userRepository; this.userManagementProperties = userManagementProperties; } /** * List all users in no given order. */
public List<User> list() {
BudgetFreak/BudgetFreak
server/budgeting/src/main/java/de/budgetfreak/budgeting/specification/CategorySpecifications.java
// Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Category.java // @Entity(name = "BF_CATEGORY") // public class Category { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "MASTERCATEGORY_ID") // private MasterCategory masterCategory; // // public Long getId() { // return id; // } // // public Category setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public Category setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public Category setDescription(String description) { // this.description = description; // return this; // } // // public MasterCategory getMasterCategory() { // return masterCategory; // } // // public Category setMasterCategory(MasterCategory masterCategory) { // this.masterCategory = masterCategory; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import de.budgetfreak.budgeting.domain.Category; import de.budgetfreak.budgeting.domain.Category_; import de.budgetfreak.budgeting.domain.MasterCategory_; import de.budgetfreak.usermanagement.domain.User; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Component;
package de.budgetfreak.budgeting.specification; /** * {@link Specification}s for {@link Category}-entities. */ @Component public class CategorySpecifications {
// Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Category.java // @Entity(name = "BF_CATEGORY") // public class Category { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "MASTERCATEGORY_ID") // private MasterCategory masterCategory; // // public Long getId() { // return id; // } // // public Category setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public Category setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public Category setDescription(String description) { // this.description = description; // return this; // } // // public MasterCategory getMasterCategory() { // return masterCategory; // } // // public Category setMasterCategory(MasterCategory masterCategory) { // this.masterCategory = masterCategory; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/specification/CategorySpecifications.java import de.budgetfreak.budgeting.domain.Category; import de.budgetfreak.budgeting.domain.Category_; import de.budgetfreak.budgeting.domain.MasterCategory_; import de.budgetfreak.usermanagement.domain.User; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Component; package de.budgetfreak.budgeting.specification; /** * {@link Specification}s for {@link Category}-entities. */ @Component public class CategorySpecifications {
public Specification<Category> byUser(User user) {
BudgetFreak/BudgetFreak
server/budgeting/src/main/java/de/budgetfreak/budgeting/specification/CategorySpecifications.java
// Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Category.java // @Entity(name = "BF_CATEGORY") // public class Category { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "MASTERCATEGORY_ID") // private MasterCategory masterCategory; // // public Long getId() { // return id; // } // // public Category setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public Category setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public Category setDescription(String description) { // this.description = description; // return this; // } // // public MasterCategory getMasterCategory() { // return masterCategory; // } // // public Category setMasterCategory(MasterCategory masterCategory) { // this.masterCategory = masterCategory; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import de.budgetfreak.budgeting.domain.Category; import de.budgetfreak.budgeting.domain.Category_; import de.budgetfreak.budgeting.domain.MasterCategory_; import de.budgetfreak.usermanagement.domain.User; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Component;
package de.budgetfreak.budgeting.specification; /** * {@link Specification}s for {@link Category}-entities. */ @Component public class CategorySpecifications {
// Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Category.java // @Entity(name = "BF_CATEGORY") // public class Category { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "MASTERCATEGORY_ID") // private MasterCategory masterCategory; // // public Long getId() { // return id; // } // // public Category setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public Category setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public Category setDescription(String description) { // this.description = description; // return this; // } // // public MasterCategory getMasterCategory() { // return masterCategory; // } // // public Category setMasterCategory(MasterCategory masterCategory) { // this.masterCategory = masterCategory; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/specification/CategorySpecifications.java import de.budgetfreak.budgeting.domain.Category; import de.budgetfreak.budgeting.domain.Category_; import de.budgetfreak.budgeting.domain.MasterCategory_; import de.budgetfreak.usermanagement.domain.User; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Component; package de.budgetfreak.budgeting.specification; /** * {@link Specification}s for {@link Category}-entities. */ @Component public class CategorySpecifications {
public Specification<Category> byUser(User user) {
BudgetFreak/BudgetFreak
server/user-management/src/test/java/de/budgetfreak/usermanagement/service/UserServiceTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.UserTestUtils; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*;
package de.budgetfreak.usermanagement.service; public class UserServiceTest { private UserService testSubject;
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/service/UserServiceTest.java import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.UserTestUtils; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; package de.budgetfreak.usermanagement.service; public class UserServiceTest { private UserService testSubject;
private UserRepository userRepositoryMock;
BudgetFreak/BudgetFreak
server/user-management/src/test/java/de/budgetfreak/usermanagement/service/UserServiceTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.UserTestUtils; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*;
package de.budgetfreak.usermanagement.service; public class UserServiceTest { private UserService testSubject; private UserRepository userRepositoryMock;
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/service/UserServiceTest.java import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.UserTestUtils; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; package de.budgetfreak.usermanagement.service; public class UserServiceTest { private UserService testSubject; private UserRepository userRepositoryMock;
private UserManagementProperties userManagementProperties;
BudgetFreak/BudgetFreak
server/user-management/src/test/java/de/budgetfreak/usermanagement/service/UserServiceTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.UserTestUtils; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*;
package de.budgetfreak.usermanagement.service; public class UserServiceTest { private UserService testSubject; private UserRepository userRepositoryMock; private UserManagementProperties userManagementProperties; @Before public void setUp() throws Exception { userRepositoryMock = mock(UserRepository.class); userManagementProperties = new UserManagementProperties().setTestProperty("mockedTestProperty"); testSubject = new UserService(userRepositoryMock, userManagementProperties); } @Test public void shouldCreateUser() throws Exception {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/service/UserServiceTest.java import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.UserTestUtils; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; package de.budgetfreak.usermanagement.service; public class UserServiceTest { private UserService testSubject; private UserRepository userRepositoryMock; private UserManagementProperties userManagementProperties; @Before public void setUp() throws Exception { userRepositoryMock = mock(UserRepository.class); userManagementProperties = new UserManagementProperties().setTestProperty("mockedTestProperty"); testSubject = new UserService(userRepositoryMock, userManagementProperties); } @Test public void shouldCreateUser() throws Exception {
when(userRepositoryMock.save(isA(User.class))).thenAnswer(invocation -> invocation.getArgument(0));
BudgetFreak/BudgetFreak
server/user-management/src/test/java/de/budgetfreak/usermanagement/service/UserServiceTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.UserTestUtils; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*;
package de.budgetfreak.usermanagement.service; public class UserServiceTest { private UserService testSubject; private UserRepository userRepositoryMock; private UserManagementProperties userManagementProperties; @Before public void setUp() throws Exception { userRepositoryMock = mock(UserRepository.class); userManagementProperties = new UserManagementProperties().setTestProperty("mockedTestProperty"); testSubject = new UserService(userRepositoryMock, userManagementProperties); } @Test public void shouldCreateUser() throws Exception { when(userRepositoryMock.save(isA(User.class))).thenAnswer(invocation -> invocation.getArgument(0)); final User user = testSubject.create("Clark", "$"); assertThat(user.getName()).isEqualTo("Clark"); assertThat(user.getCurrency()).isEqualTo("$"); } @Test public void shouldReturnAllUser() throws Exception {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/UserManagementProperties.java // @ConfigurationProperties("usermanagement") // public class UserManagementProperties { // // private String testProperty; // // public String getTestProperty() { // return testProperty; // } // // public UserManagementProperties setTestProperty(String testProperty) { // this.testProperty = testProperty; // return this; // } // } // // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/service/UserServiceTest.java import de.budgetfreak.usermanagement.UserManagementProperties; import de.budgetfreak.usermanagement.UserTestUtils; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Example; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; package de.budgetfreak.usermanagement.service; public class UserServiceTest { private UserService testSubject; private UserRepository userRepositoryMock; private UserManagementProperties userManagementProperties; @Before public void setUp() throws Exception { userRepositoryMock = mock(UserRepository.class); userManagementProperties = new UserManagementProperties().setTestProperty("mockedTestProperty"); testSubject = new UserService(userRepositoryMock, userManagementProperties); } @Test public void shouldCreateUser() throws Exception { when(userRepositoryMock.save(isA(User.class))).thenAnswer(invocation -> invocation.getArgument(0)); final User user = testSubject.create("Clark", "$"); assertThat(user.getName()).isEqualTo("Clark"); assertThat(user.getCurrency()).isEqualTo("$"); } @Test public void shouldReturnAllUser() throws Exception {
final List<User> bobAndJane = UserTestUtils.createBobAndJane();
BudgetFreak/BudgetFreak
server/user-management/src/main/java/de/budgetfreak/usermanagement/web/UserController.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/service/UserService.java // @Service // @EnableConfigurationProperties(UserManagementProperties.class) // public class UserService { // // private UserRepository userRepository; // private UserManagementProperties userManagementProperties; // // @Autowired // public UserService(UserRepository userRepository, UserManagementProperties userManagementProperties) { // this.userRepository = userRepository; // this.userManagementProperties = userManagementProperties; // } // // /** // * List all users in no given order. // */ // public List<User> list() { // return userRepository.findAll(); // } // // /** // * Create and saves an user. // * // * @return The created entity. // */ // public User create(String name, String currency) { // final User user = new User(name, currency); // return userRepository.save(user); // } // // /** // * Get one user by id. // */ // public User get(long id) { // return userRepository.findOne(Example.of(new User().setId(id))).orElse(null); // } // // /** // * Reads the testProperty. // * // * @return The configured property. // */ // public String getTestProperty() { // return userManagementProperties.getTestProperty(); // } // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.Link; import org.springframework.hateoas.Resource; import org.springframework.hateoas.Resources; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
package de.budgetfreak.usermanagement.web; /** * Controller for accessing users. */ @RestController @RequestMapping("/users") public class UserController {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/service/UserService.java // @Service // @EnableConfigurationProperties(UserManagementProperties.class) // public class UserService { // // private UserRepository userRepository; // private UserManagementProperties userManagementProperties; // // @Autowired // public UserService(UserRepository userRepository, UserManagementProperties userManagementProperties) { // this.userRepository = userRepository; // this.userManagementProperties = userManagementProperties; // } // // /** // * List all users in no given order. // */ // public List<User> list() { // return userRepository.findAll(); // } // // /** // * Create and saves an user. // * // * @return The created entity. // */ // public User create(String name, String currency) { // final User user = new User(name, currency); // return userRepository.save(user); // } // // /** // * Get one user by id. // */ // public User get(long id) { // return userRepository.findOne(Example.of(new User().setId(id))).orElse(null); // } // // /** // * Reads the testProperty. // * // * @return The configured property. // */ // public String getTestProperty() { // return userManagementProperties.getTestProperty(); // } // } // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/web/UserController.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.Link; import org.springframework.hateoas.Resource; import org.springframework.hateoas.Resources; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; package de.budgetfreak.usermanagement.web; /** * Controller for accessing users. */ @RestController @RequestMapping("/users") public class UserController {
private UserService userService;
BudgetFreak/BudgetFreak
server/user-management/src/main/java/de/budgetfreak/usermanagement/web/UserController.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/service/UserService.java // @Service // @EnableConfigurationProperties(UserManagementProperties.class) // public class UserService { // // private UserRepository userRepository; // private UserManagementProperties userManagementProperties; // // @Autowired // public UserService(UserRepository userRepository, UserManagementProperties userManagementProperties) { // this.userRepository = userRepository; // this.userManagementProperties = userManagementProperties; // } // // /** // * List all users in no given order. // */ // public List<User> list() { // return userRepository.findAll(); // } // // /** // * Create and saves an user. // * // * @return The created entity. // */ // public User create(String name, String currency) { // final User user = new User(name, currency); // return userRepository.save(user); // } // // /** // * Get one user by id. // */ // public User get(long id) { // return userRepository.findOne(Example.of(new User().setId(id))).orElse(null); // } // // /** // * Reads the testProperty. // * // * @return The configured property. // */ // public String getTestProperty() { // return userManagementProperties.getTestProperty(); // } // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.Link; import org.springframework.hateoas.Resource; import org.springframework.hateoas.Resources; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
package de.budgetfreak.usermanagement.web; /** * Controller for accessing users. */ @RestController @RequestMapping("/users") public class UserController { private UserService userService; private UserResourceAssembler userResourceAssembler; @InitBinder protected void initBinder(WebDataBinder binder) { // TODO Maybe define global validators? binder.setValidator(new UserResourceValidator()); } @Autowired public UserController(UserService userService, UserResourceAssembler userResourceAssembler) { this.userService = userService; this.userResourceAssembler = userResourceAssembler; } /** * List all users in no given order. */ @GetMapping public Resources<UserResource> list() {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/service/UserService.java // @Service // @EnableConfigurationProperties(UserManagementProperties.class) // public class UserService { // // private UserRepository userRepository; // private UserManagementProperties userManagementProperties; // // @Autowired // public UserService(UserRepository userRepository, UserManagementProperties userManagementProperties) { // this.userRepository = userRepository; // this.userManagementProperties = userManagementProperties; // } // // /** // * List all users in no given order. // */ // public List<User> list() { // return userRepository.findAll(); // } // // /** // * Create and saves an user. // * // * @return The created entity. // */ // public User create(String name, String currency) { // final User user = new User(name, currency); // return userRepository.save(user); // } // // /** // * Get one user by id. // */ // public User get(long id) { // return userRepository.findOne(Example.of(new User().setId(id))).orElse(null); // } // // /** // * Reads the testProperty. // * // * @return The configured property. // */ // public String getTestProperty() { // return userManagementProperties.getTestProperty(); // } // } // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/web/UserController.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.Link; import org.springframework.hateoas.Resource; import org.springframework.hateoas.Resources; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; package de.budgetfreak.usermanagement.web; /** * Controller for accessing users. */ @RestController @RequestMapping("/users") public class UserController { private UserService userService; private UserResourceAssembler userResourceAssembler; @InitBinder protected void initBinder(WebDataBinder binder) { // TODO Maybe define global validators? binder.setValidator(new UserResourceValidator()); } @Autowired public UserController(UserService userService, UserResourceAssembler userResourceAssembler) { this.userService = userService; this.userResourceAssembler = userResourceAssembler; } /** * List all users in no given order. */ @GetMapping public Resources<UserResource> list() {
List<User> users = userService.list();
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/specification/CategorySpecificationsTest.java
// Path: server/budgeting/src/test/java/de/budgetfreak/BudgetingIntegrationTestApplication.java // @SpringBootApplication // public class BudgetingIntegrationTestApplication { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Category.java // @Entity(name = "BF_CATEGORY") // public class Category { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "MASTERCATEGORY_ID") // private MasterCategory masterCategory; // // public Long getId() { // return id; // } // // public Category setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public Category setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public Category setDescription(String description) { // this.description = description; // return this; // } // // public MasterCategory getMasterCategory() { // return masterCategory; // } // // public Category setMasterCategory(MasterCategory masterCategory) { // this.masterCategory = masterCategory; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long>, JpaSpecificationExecutor<Category> { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategory.java // @Entity(name = "BF_MASTERCATEGORY") // public class MasterCategory { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Long getId() { // return id; // } // // public MasterCategory setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public MasterCategory setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public MasterCategory setDescription(String description) { // this.description = description; // return this; // } // // public User getUser() { // return user; // } // // public MasterCategory setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategoryRepository.java // public interface MasterCategoryRepository extends JpaRepository<MasterCategory, Long> { // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.BudgetingIntegrationTestApplication; import de.budgetfreak.budgeting.domain.Category; import de.budgetfreak.budgeting.domain.CategoryRepository; import de.budgetfreak.budgeting.domain.MasterCategory; import de.budgetfreak.budgeting.domain.MasterCategoryRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.jpa.domain.Specification; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.specification; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BudgetingIntegrationTestApplication.class) @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) public class CategorySpecificationsTest { @Autowired private CategorySpecifications testSubject; @Autowired
// Path: server/budgeting/src/test/java/de/budgetfreak/BudgetingIntegrationTestApplication.java // @SpringBootApplication // public class BudgetingIntegrationTestApplication { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Category.java // @Entity(name = "BF_CATEGORY") // public class Category { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "MASTERCATEGORY_ID") // private MasterCategory masterCategory; // // public Long getId() { // return id; // } // // public Category setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public Category setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public Category setDescription(String description) { // this.description = description; // return this; // } // // public MasterCategory getMasterCategory() { // return masterCategory; // } // // public Category setMasterCategory(MasterCategory masterCategory) { // this.masterCategory = masterCategory; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long>, JpaSpecificationExecutor<Category> { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategory.java // @Entity(name = "BF_MASTERCATEGORY") // public class MasterCategory { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Long getId() { // return id; // } // // public MasterCategory setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public MasterCategory setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public MasterCategory setDescription(String description) { // this.description = description; // return this; // } // // public User getUser() { // return user; // } // // public MasterCategory setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategoryRepository.java // public interface MasterCategoryRepository extends JpaRepository<MasterCategory, Long> { // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/specification/CategorySpecificationsTest.java import de.budgetfreak.BudgetingIntegrationTestApplication; import de.budgetfreak.budgeting.domain.Category; import de.budgetfreak.budgeting.domain.CategoryRepository; import de.budgetfreak.budgeting.domain.MasterCategory; import de.budgetfreak.budgeting.domain.MasterCategoryRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.jpa.domain.Specification; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.specification; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BudgetingIntegrationTestApplication.class) @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) public class CategorySpecificationsTest { @Autowired private CategorySpecifications testSubject; @Autowired
private UserRepository userRepository;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/specification/CategorySpecificationsTest.java
// Path: server/budgeting/src/test/java/de/budgetfreak/BudgetingIntegrationTestApplication.java // @SpringBootApplication // public class BudgetingIntegrationTestApplication { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Category.java // @Entity(name = "BF_CATEGORY") // public class Category { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "MASTERCATEGORY_ID") // private MasterCategory masterCategory; // // public Long getId() { // return id; // } // // public Category setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public Category setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public Category setDescription(String description) { // this.description = description; // return this; // } // // public MasterCategory getMasterCategory() { // return masterCategory; // } // // public Category setMasterCategory(MasterCategory masterCategory) { // this.masterCategory = masterCategory; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long>, JpaSpecificationExecutor<Category> { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategory.java // @Entity(name = "BF_MASTERCATEGORY") // public class MasterCategory { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Long getId() { // return id; // } // // public MasterCategory setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public MasterCategory setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public MasterCategory setDescription(String description) { // this.description = description; // return this; // } // // public User getUser() { // return user; // } // // public MasterCategory setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategoryRepository.java // public interface MasterCategoryRepository extends JpaRepository<MasterCategory, Long> { // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.BudgetingIntegrationTestApplication; import de.budgetfreak.budgeting.domain.Category; import de.budgetfreak.budgeting.domain.CategoryRepository; import de.budgetfreak.budgeting.domain.MasterCategory; import de.budgetfreak.budgeting.domain.MasterCategoryRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.jpa.domain.Specification; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.specification; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BudgetingIntegrationTestApplication.class) @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) public class CategorySpecificationsTest { @Autowired private CategorySpecifications testSubject; @Autowired private UserRepository userRepository; @Autowired
// Path: server/budgeting/src/test/java/de/budgetfreak/BudgetingIntegrationTestApplication.java // @SpringBootApplication // public class BudgetingIntegrationTestApplication { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Category.java // @Entity(name = "BF_CATEGORY") // public class Category { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "MASTERCATEGORY_ID") // private MasterCategory masterCategory; // // public Long getId() { // return id; // } // // public Category setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public Category setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public Category setDescription(String description) { // this.description = description; // return this; // } // // public MasterCategory getMasterCategory() { // return masterCategory; // } // // public Category setMasterCategory(MasterCategory masterCategory) { // this.masterCategory = masterCategory; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long>, JpaSpecificationExecutor<Category> { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategory.java // @Entity(name = "BF_MASTERCATEGORY") // public class MasterCategory { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Long getId() { // return id; // } // // public MasterCategory setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public MasterCategory setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public MasterCategory setDescription(String description) { // this.description = description; // return this; // } // // public User getUser() { // return user; // } // // public MasterCategory setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategoryRepository.java // public interface MasterCategoryRepository extends JpaRepository<MasterCategory, Long> { // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/specification/CategorySpecificationsTest.java import de.budgetfreak.BudgetingIntegrationTestApplication; import de.budgetfreak.budgeting.domain.Category; import de.budgetfreak.budgeting.domain.CategoryRepository; import de.budgetfreak.budgeting.domain.MasterCategory; import de.budgetfreak.budgeting.domain.MasterCategoryRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.jpa.domain.Specification; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.specification; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BudgetingIntegrationTestApplication.class) @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) public class CategorySpecificationsTest { @Autowired private CategorySpecifications testSubject; @Autowired private UserRepository userRepository; @Autowired
private MasterCategoryRepository masterCategoryRepository;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/specification/CategorySpecificationsTest.java
// Path: server/budgeting/src/test/java/de/budgetfreak/BudgetingIntegrationTestApplication.java // @SpringBootApplication // public class BudgetingIntegrationTestApplication { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Category.java // @Entity(name = "BF_CATEGORY") // public class Category { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "MASTERCATEGORY_ID") // private MasterCategory masterCategory; // // public Long getId() { // return id; // } // // public Category setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public Category setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public Category setDescription(String description) { // this.description = description; // return this; // } // // public MasterCategory getMasterCategory() { // return masterCategory; // } // // public Category setMasterCategory(MasterCategory masterCategory) { // this.masterCategory = masterCategory; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long>, JpaSpecificationExecutor<Category> { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategory.java // @Entity(name = "BF_MASTERCATEGORY") // public class MasterCategory { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Long getId() { // return id; // } // // public MasterCategory setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public MasterCategory setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public MasterCategory setDescription(String description) { // this.description = description; // return this; // } // // public User getUser() { // return user; // } // // public MasterCategory setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategoryRepository.java // public interface MasterCategoryRepository extends JpaRepository<MasterCategory, Long> { // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.BudgetingIntegrationTestApplication; import de.budgetfreak.budgeting.domain.Category; import de.budgetfreak.budgeting.domain.CategoryRepository; import de.budgetfreak.budgeting.domain.MasterCategory; import de.budgetfreak.budgeting.domain.MasterCategoryRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.jpa.domain.Specification; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.specification; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BudgetingIntegrationTestApplication.class) @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) public class CategorySpecificationsTest { @Autowired private CategorySpecifications testSubject; @Autowired private UserRepository userRepository; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired
// Path: server/budgeting/src/test/java/de/budgetfreak/BudgetingIntegrationTestApplication.java // @SpringBootApplication // public class BudgetingIntegrationTestApplication { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Category.java // @Entity(name = "BF_CATEGORY") // public class Category { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "MASTERCATEGORY_ID") // private MasterCategory masterCategory; // // public Long getId() { // return id; // } // // public Category setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public Category setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public Category setDescription(String description) { // this.description = description; // return this; // } // // public MasterCategory getMasterCategory() { // return masterCategory; // } // // public Category setMasterCategory(MasterCategory masterCategory) { // this.masterCategory = masterCategory; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long>, JpaSpecificationExecutor<Category> { // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategory.java // @Entity(name = "BF_MASTERCATEGORY") // public class MasterCategory { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "DESCRIPTION") // private String description; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Long getId() { // return id; // } // // public MasterCategory setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public MasterCategory setName(String name) { // this.name = name; // return this; // } // // public String getDescription() { // return description; // } // // public MasterCategory setDescription(String description) { // this.description = description; // return this; // } // // public User getUser() { // return user; // } // // public MasterCategory setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategoryRepository.java // public interface MasterCategoryRepository extends JpaRepository<MasterCategory, Long> { // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/specification/CategorySpecificationsTest.java import de.budgetfreak.BudgetingIntegrationTestApplication; import de.budgetfreak.budgeting.domain.Category; import de.budgetfreak.budgeting.domain.CategoryRepository; import de.budgetfreak.budgeting.domain.MasterCategory; import de.budgetfreak.budgeting.domain.MasterCategoryRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.jpa.domain.Specification; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.specification; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BudgetingIntegrationTestApplication.class) @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) public class CategorySpecificationsTest { @Autowired private CategorySpecifications testSubject; @Autowired private UserRepository userRepository; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired
private CategoryRepository categoryRepository;
BudgetFreak/BudgetFreak
server/user-management/src/main/java/de/budgetfreak/usermanagement/web/UserResourceAssembler.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/utils/web/src/main/java/de/budgetfreak/utils/web/ResourceAssembler.java // public abstract class ResourceAssembler<E, R extends ResourceSupport> extends ResourceAssemblerSupport<E, R> { // // private List<ResourceLinks<E>> resourceLinkFactories; // // public ResourceAssembler(Class<?> controllerClass, Class<R> resourceType, List<ResourceLinks<E>> resourceLinkFactories) { // super(controllerClass, resourceType); // this.resourceLinkFactories = resourceLinkFactories; // } // // /** // * Converts the given entity to a {@link ResourceSupport} and adds all {@link Link}s via the available {@link ResourceLinks}. // * // * @param entity The entity to convert. // * @return The {@link ResourceSupport} representation. // * @see org.springframework.hateoas.ResourceAssembler#toResource(Object) // */ // @Override // public R toResource(E entity) { // R resource = createResource(entity); // // Collection<Link> resourceLinks = findResourceLinks(entity); // resource.add(resourceLinks); // // return resource; // } // // protected abstract R createResource(E entity); // // /** // * Searches the Spring context for all {@link ResourceLinks} which can handle the class of the given entity. // * // * @param entity Entity to create the {link Link}s for. // * @return A list of all links for this entity. // */ // private Collection<Link> findResourceLinks(E entity) { // List<Link> links = new ArrayList<>(); // resourceLinkFactories.stream().filter(link -> link.accepts(entity.getClass())).forEach(link -> links.addAll(link.generateLinks(entity))); // return links; // } // } // // Path: server/utils/web/src/main/java/de/budgetfreak/utils/web/ResourceLinks.java // public abstract class ResourceLinks<E> { // private Class<E> targetType; // // public ResourceLinks(Class<E> targetType) { // this.targetType = targetType; // } // // public abstract Collection<Link> generateLinks(E entity); // // public boolean accepts(Class<?> targetClass) { // return targetClass == targetType; // } // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.utils.web.ResourceAssembler; import de.budgetfreak.utils.web.ResourceLinks; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List;
package de.budgetfreak.usermanagement.web; /** * Assembler for converting an {@link User} into an {@link UserResource}. */ @Component public class UserResourceAssembler extends ResourceAssembler<User, UserResource> { @Autowired
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/utils/web/src/main/java/de/budgetfreak/utils/web/ResourceAssembler.java // public abstract class ResourceAssembler<E, R extends ResourceSupport> extends ResourceAssemblerSupport<E, R> { // // private List<ResourceLinks<E>> resourceLinkFactories; // // public ResourceAssembler(Class<?> controllerClass, Class<R> resourceType, List<ResourceLinks<E>> resourceLinkFactories) { // super(controllerClass, resourceType); // this.resourceLinkFactories = resourceLinkFactories; // } // // /** // * Converts the given entity to a {@link ResourceSupport} and adds all {@link Link}s via the available {@link ResourceLinks}. // * // * @param entity The entity to convert. // * @return The {@link ResourceSupport} representation. // * @see org.springframework.hateoas.ResourceAssembler#toResource(Object) // */ // @Override // public R toResource(E entity) { // R resource = createResource(entity); // // Collection<Link> resourceLinks = findResourceLinks(entity); // resource.add(resourceLinks); // // return resource; // } // // protected abstract R createResource(E entity); // // /** // * Searches the Spring context for all {@link ResourceLinks} which can handle the class of the given entity. // * // * @param entity Entity to create the {link Link}s for. // * @return A list of all links for this entity. // */ // private Collection<Link> findResourceLinks(E entity) { // List<Link> links = new ArrayList<>(); // resourceLinkFactories.stream().filter(link -> link.accepts(entity.getClass())).forEach(link -> links.addAll(link.generateLinks(entity))); // return links; // } // } // // Path: server/utils/web/src/main/java/de/budgetfreak/utils/web/ResourceLinks.java // public abstract class ResourceLinks<E> { // private Class<E> targetType; // // public ResourceLinks(Class<E> targetType) { // this.targetType = targetType; // } // // public abstract Collection<Link> generateLinks(E entity); // // public boolean accepts(Class<?> targetClass) { // return targetClass == targetType; // } // } // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/web/UserResourceAssembler.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.utils.web.ResourceAssembler; import de.budgetfreak.utils.web.ResourceLinks; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; package de.budgetfreak.usermanagement.web; /** * Assembler for converting an {@link User} into an {@link UserResource}. */ @Component public class UserResourceAssembler extends ResourceAssembler<User, UserResource> { @Autowired
public UserResourceAssembler(List<ResourceLinks<User>> resourceLinks) {
BudgetFreak/BudgetFreak
server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategory.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import de.budgetfreak.usermanagement.domain.User; import javax.persistence.*;
package de.budgetfreak.budgeting.domain; /** * A {@link MasterCategory} is the container for several {@link Category}-entities and used for * displaying accumulated data. */ @Entity(name = "BF_MASTERCATEGORY") public class MasterCategory { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "NAME") private String name; @Column(name = "DESCRIPTION") private String description; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "USER_ID")
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/MasterCategory.java import de.budgetfreak.usermanagement.domain.User; import javax.persistence.*; package de.budgetfreak.budgeting.domain; /** * A {@link MasterCategory} is the container for several {@link Category}-entities and used for * displaying accumulated data. */ @Entity(name = "BF_MASTERCATEGORY") public class MasterCategory { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "NAME") private String name; @Column(name = "DESCRIPTION") private String description; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "USER_ID")
private User user;
BudgetFreak/BudgetFreak
server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Transaction.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // }
import de.budgetfreak.accounting.domain.Account; import javax.persistence.*; import java.math.BigDecimal; import java.util.Date;
package de.budgetfreak.budgeting.domain; /** * A transaction is money spent issued to a {@link Payee}. * Transactions are assigned to an {@link Account} and a {@link Category}. */ @Entity(name = "BF_TRANSACTION") public class Transaction { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "AMOUNT") private BigDecimal amount; @Column(name = "BOOKING_DATE") private Date bookingDate; @Column(name = "DESCRIPTION") private String description; @Column(name = "CLEARED") private boolean cleared; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "PAYEE_ID") private Payee payee; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "CATEGORY_ID") private Category category; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "ACCOUNT_ID")
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // Path: server/budgeting/src/main/java/de/budgetfreak/budgeting/domain/Transaction.java import de.budgetfreak.accounting.domain.Account; import javax.persistence.*; import java.math.BigDecimal; import java.util.Date; package de.budgetfreak.budgeting.domain; /** * A transaction is money spent issued to a {@link Payee}. * Transactions are assigned to an {@link Account} and a {@link Category}. */ @Entity(name = "BF_TRANSACTION") public class Transaction { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "AMOUNT") private BigDecimal amount; @Column(name = "BOOKING_DATE") private Date bookingDate; @Column(name = "DESCRIPTION") private String description; @Column(name = "CLEARED") private boolean cleared; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "PAYEE_ID") private Payee payee; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "CATEGORY_ID") private Category category; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "ACCOUNT_ID")
private Account account;
BudgetFreak/BudgetFreak
server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List;
package de.budgetfreak.accounting.service; /** * Service for managing accounts. */ @Service public class AccountService {
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List; package de.budgetfreak.accounting.service; /** * Service for managing accounts. */ @Service public class AccountService {
private AccountRepository accountRepository;
BudgetFreak/BudgetFreak
server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List;
package de.budgetfreak.accounting.service; /** * Service for managing accounts. */ @Service public class AccountService { private AccountRepository accountRepository;
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List; package de.budgetfreak.accounting.service; /** * Service for managing accounts. */ @Service public class AccountService { private AccountRepository accountRepository;
private UserRepository userRepository;
BudgetFreak/BudgetFreak
server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List;
package de.budgetfreak.accounting.service; /** * Service for managing accounts. */ @Service public class AccountService { private AccountRepository accountRepository; private UserRepository userRepository; @Autowired public AccountService(AccountRepository accountRepository, UserRepository userRepository) { this.accountRepository = accountRepository; this.userRepository = userRepository; } /** * Lists all accounts. * * @param userId The id of the user who's account we want to access. */
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List; package de.budgetfreak.accounting.service; /** * Service for managing accounts. */ @Service public class AccountService { private AccountRepository accountRepository; private UserRepository userRepository; @Autowired public AccountService(AccountRepository accountRepository, UserRepository userRepository) { this.accountRepository = accountRepository; this.userRepository = userRepository; } /** * Lists all accounts. * * @param userId The id of the user who's account we want to access. */
public List<Account> list(long userId) {
BudgetFreak/BudgetFreak
server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List;
package de.budgetfreak.accounting.service; /** * Service for managing accounts. */ @Service public class AccountService { private AccountRepository accountRepository; private UserRepository userRepository; @Autowired public AccountService(AccountRepository accountRepository, UserRepository userRepository) { this.accountRepository = accountRepository; this.userRepository = userRepository; } /** * Lists all accounts. * * @param userId The id of the user who's account we want to access. */ public List<Account> list(long userId) { return accountRepository.findByUserId(userId); } /** * Returns one account by id. * * @param id The id of the account. */ public Account get(long id) { return accountRepository.findOne(Example.of(new Account().setId(id))).orElse(null); } /** * Creates an account. * * @param userId The user the account will belong to. * @param description The description. * @param onBudget Whether the account will have an effect on the budget. */ public Account create(long userId, String description, boolean onBudget) {
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/AccountRepository.java // public interface AccountRepository extends JpaRepository<Account, Long> { // // List<Account> findByUserId(long userId); // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.domain.AccountRepository; import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.stereotype.Service; import java.util.List; package de.budgetfreak.accounting.service; /** * Service for managing accounts. */ @Service public class AccountService { private AccountRepository accountRepository; private UserRepository userRepository; @Autowired public AccountService(AccountRepository accountRepository, UserRepository userRepository) { this.accountRepository = accountRepository; this.userRepository = userRepository; } /** * Lists all accounts. * * @param userId The id of the user who's account we want to access. */ public List<Account> list(long userId) { return accountRepository.findByUserId(userId); } /** * Returns one account by id. * * @param id The id of the account. */ public Account get(long id) { return accountRepository.findOne(Example.of(new Account().setId(id))).orElse(null); } /** * Creates an account. * * @param userId The user the account will belong to. * @param description The description. * @param onBudget Whether the account will have an effect on the budget. */ public Account create(long userId, String description, boolean onBudget) {
User user = userRepository.getOne(userId);
BudgetFreak/BudgetFreak
server/accounting/src/main/java/de/budgetfreak/accounting/web/AccountController.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java // @Service // public class AccountService { // // private AccountRepository accountRepository; // private UserRepository userRepository; // // @Autowired // public AccountService(AccountRepository accountRepository, UserRepository userRepository) { // this.accountRepository = accountRepository; // this.userRepository = userRepository; // } // // /** // * Lists all accounts. // * // * @param userId The id of the user who's account we want to access. // */ // public List<Account> list(long userId) { // return accountRepository.findByUserId(userId); // } // // /** // * Returns one account by id. // * // * @param id The id of the account. // */ // public Account get(long id) { // return accountRepository.findOne(Example.of(new Account().setId(id))).orElse(null); // } // // /** // * Creates an account. // * // * @param userId The user the account will belong to. // * @param description The description. // * @param onBudget Whether the account will have an effect on the budget. // */ // public Account create(long userId, String description, boolean onBudget) { // User user = userRepository.getOne(userId); // Account account = new Account(description, onBudget, user); // return accountRepository.saveAndFlush(account); // } // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.service.AccountService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.Link; import org.springframework.hateoas.Resource; import org.springframework.hateoas.Resources; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
package de.budgetfreak.accounting.web; /** * Controller for accessing accounts. */ @RestController @RequestMapping("/users/{userId}/accounts") public class AccountController {
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java // @Service // public class AccountService { // // private AccountRepository accountRepository; // private UserRepository userRepository; // // @Autowired // public AccountService(AccountRepository accountRepository, UserRepository userRepository) { // this.accountRepository = accountRepository; // this.userRepository = userRepository; // } // // /** // * Lists all accounts. // * // * @param userId The id of the user who's account we want to access. // */ // public List<Account> list(long userId) { // return accountRepository.findByUserId(userId); // } // // /** // * Returns one account by id. // * // * @param id The id of the account. // */ // public Account get(long id) { // return accountRepository.findOne(Example.of(new Account().setId(id))).orElse(null); // } // // /** // * Creates an account. // * // * @param userId The user the account will belong to. // * @param description The description. // * @param onBudget Whether the account will have an effect on the budget. // */ // public Account create(long userId, String description, boolean onBudget) { // User user = userRepository.getOne(userId); // Account account = new Account(description, onBudget, user); // return accountRepository.saveAndFlush(account); // } // } // Path: server/accounting/src/main/java/de/budgetfreak/accounting/web/AccountController.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.service.AccountService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.Link; import org.springframework.hateoas.Resource; import org.springframework.hateoas.Resources; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; package de.budgetfreak.accounting.web; /** * Controller for accessing accounts. */ @RestController @RequestMapping("/users/{userId}/accounts") public class AccountController {
private AccountService accountService;
BudgetFreak/BudgetFreak
server/accounting/src/main/java/de/budgetfreak/accounting/web/AccountController.java
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java // @Service // public class AccountService { // // private AccountRepository accountRepository; // private UserRepository userRepository; // // @Autowired // public AccountService(AccountRepository accountRepository, UserRepository userRepository) { // this.accountRepository = accountRepository; // this.userRepository = userRepository; // } // // /** // * Lists all accounts. // * // * @param userId The id of the user who's account we want to access. // */ // public List<Account> list(long userId) { // return accountRepository.findByUserId(userId); // } // // /** // * Returns one account by id. // * // * @param id The id of the account. // */ // public Account get(long id) { // return accountRepository.findOne(Example.of(new Account().setId(id))).orElse(null); // } // // /** // * Creates an account. // * // * @param userId The user the account will belong to. // * @param description The description. // * @param onBudget Whether the account will have an effect on the budget. // */ // public Account create(long userId, String description, boolean onBudget) { // User user = userRepository.getOne(userId); // Account account = new Account(description, onBudget, user); // return accountRepository.saveAndFlush(account); // } // }
import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.service.AccountService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.Link; import org.springframework.hateoas.Resource; import org.springframework.hateoas.Resources; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
package de.budgetfreak.accounting.web; /** * Controller for accessing accounts. */ @RestController @RequestMapping("/users/{userId}/accounts") public class AccountController { private AccountService accountService; private AccountResourceAssembler accountResourceAssembler; @InitBinder protected void initBinder(WebDataBinder binder) { binder.setValidator(new AccountResourceValidator()); } @Autowired public AccountController(AccountService accountService, AccountResourceAssembler accountResourceAssembler) { this.accountService = accountService; this.accountResourceAssembler = accountResourceAssembler; } /** * List all accounts in no given order. */ @GetMapping public Resources<AccountResource> list(@PathVariable("userId") long userId) {
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java // @Service // public class AccountService { // // private AccountRepository accountRepository; // private UserRepository userRepository; // // @Autowired // public AccountService(AccountRepository accountRepository, UserRepository userRepository) { // this.accountRepository = accountRepository; // this.userRepository = userRepository; // } // // /** // * Lists all accounts. // * // * @param userId The id of the user who's account we want to access. // */ // public List<Account> list(long userId) { // return accountRepository.findByUserId(userId); // } // // /** // * Returns one account by id. // * // * @param id The id of the account. // */ // public Account get(long id) { // return accountRepository.findOne(Example.of(new Account().setId(id))).orElse(null); // } // // /** // * Creates an account. // * // * @param userId The user the account will belong to. // * @param description The description. // * @param onBudget Whether the account will have an effect on the budget. // */ // public Account create(long userId, String description, boolean onBudget) { // User user = userRepository.getOne(userId); // Account account = new Account(description, onBudget, user); // return accountRepository.saveAndFlush(account); // } // } // Path: server/accounting/src/main/java/de/budgetfreak/accounting/web/AccountController.java import de.budgetfreak.accounting.domain.Account; import de.budgetfreak.accounting.service.AccountService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.Link; import org.springframework.hateoas.Resource; import org.springframework.hateoas.Resources; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; package de.budgetfreak.accounting.web; /** * Controller for accessing accounts. */ @RestController @RequestMapping("/users/{userId}/accounts") public class AccountController { private AccountService accountService; private AccountResourceAssembler accountResourceAssembler; @InitBinder protected void initBinder(WebDataBinder binder) { binder.setValidator(new AccountResourceValidator()); } @Autowired public AccountController(AccountService accountService, AccountResourceAssembler accountResourceAssembler) { this.accountService = accountService; this.accountResourceAssembler = accountResourceAssembler; } /** * List all accounts in no given order. */ @GetMapping public Resources<AccountResource> list(@PathVariable("userId") long userId) {
List<Account> accounts = accountService.list(userId);
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/web/AccountResourceAssemblerTest.java
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // }
import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import org.junit.Before; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.accounting.web; public class AccountResourceAssemblerTest { private AccountResourceAssembler testSubject; @Before public void setUp() throws Exception { testSubject = new AccountResourceAssembler(); } @Test public void shouldCreateResource() {
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/web/AccountResourceAssemblerTest.java import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import org.junit.Before; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.accounting.web; public class AccountResourceAssemblerTest { private AccountResourceAssembler testSubject; @Before public void setUp() throws Exception { testSubject = new AccountResourceAssembler(); } @Test public void shouldCreateResource() {
Account entity = AccountTestUtils.createCheckingsAccount(UserTestUtils.createBob());
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/web/AccountResourceAssemblerTest.java
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // }
import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import org.junit.Before; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.accounting.web; public class AccountResourceAssemblerTest { private AccountResourceAssembler testSubject; @Before public void setUp() throws Exception { testSubject = new AccountResourceAssembler(); } @Test public void shouldCreateResource() {
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/web/AccountResourceAssemblerTest.java import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import org.junit.Before; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.accounting.web; public class AccountResourceAssemblerTest { private AccountResourceAssembler testSubject; @Before public void setUp() throws Exception { testSubject = new AccountResourceAssembler(); } @Test public void shouldCreateResource() {
Account entity = AccountTestUtils.createCheckingsAccount(UserTestUtils.createBob());
BudgetFreak/BudgetFreak
server/accounting/src/test/java/de/budgetfreak/accounting/web/AccountResourceAssemblerTest.java
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // }
import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import org.junit.Before; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.accounting.web; public class AccountResourceAssemblerTest { private AccountResourceAssembler testSubject; @Before public void setUp() throws Exception { testSubject = new AccountResourceAssembler(); } @Test public void shouldCreateResource() {
// Path: server/accounting/src/test/java/de/budgetfreak/accounting/AccountTestUtils.java // public class AccountTestUtils { // // private AccountTestUtils() { // } // // public static List<Account> createAccounts(User user) { // return asList(createCheckingsAccount(user), createSavingsAccount(user)); // } // // public static Account createCheckingsAccount(User user) { // return createAccount(1L, "Checkings", true, user); // } // // public static Account createSavingsAccount(User user) { // return createAccount(2L, "Savings", false, user); // } // // public static Account createAccount(long id, String description, boolean onBudget, User user) { // Account account = new Account(description, onBudget, user).setId(id); // return account; // } // } // // Path: server/accounting/src/test/java/de/budgetfreak/accounting/UserTestUtils.java // public class UserTestUtils { // // private UserTestUtils() { // } // // public static List<User> createBobAndJane() { // return Arrays.asList( // createBob(), // createJane() // ); // } // // public static User createJane() { // return createUser(2L, "Jane", "$"); // } // // public static User createBob() { // return createUser(1L, "Bob", "€"); // } // // public static User createUser(long id, String name, String currency) { // return new User().setId(id).setName(name).setCurrency(currency); // } // } // // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java // @Entity(name = "BF_ACCOUNT") // public class Account { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "DESCRIPTION") // private String description; // // @Column(name = "ON_BUDGET") // private boolean onBudget; // // @ManyToOne(fetch = FetchType.LAZY) // @JoinColumn(name = "USER_ID") // private User user; // // public Account() { // } // // public Account(String description, boolean onBudget, User user) { // this.description = description; // this.onBudget = onBudget; // this.user = user; // } // // public Long getId() { // return id; // } // // public Account setId(Long id) { // this.id = id; // return this; // } // // public String getDescription() { // return description; // } // // public Account setDescription(String description) { // this.description = description; // return this; // } // // public boolean isOnBudget() { // return onBudget; // } // // public Account setOnBudget(boolean onBudget) { // this.onBudget = onBudget; // return this; // } // // public User getUser() { // return user; // } // // public Account setUser(User user) { // this.user = user; // return this; // } // } // Path: server/accounting/src/test/java/de/budgetfreak/accounting/web/AccountResourceAssemblerTest.java import de.budgetfreak.accounting.AccountTestUtils; import de.budgetfreak.accounting.UserTestUtils; import de.budgetfreak.accounting.domain.Account; import org.junit.Before; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.accounting.web; public class AccountResourceAssemblerTest { private AccountResourceAssembler testSubject; @Before public void setUp() throws Exception { testSubject = new AccountResourceAssembler(); } @Test public void shouldCreateResource() {
Account entity = AccountTestUtils.createCheckingsAccount(UserTestUtils.createBob());
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/CategoryRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class CategoryRepositoryTest { @Autowired private CategoryRepository testSubject; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/CategoryRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class CategoryRepositoryTest { @Autowired private CategoryRepository testSubject; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired
private UserRepository userRepository;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/CategoryRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class CategoryRepositoryTest { @Autowired private CategoryRepository testSubject; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired private UserRepository userRepository; @Test public void shouldSaveNewMaterCategories() {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/CategoryRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class CategoryRepositoryTest { @Autowired private CategoryRepository testSubject; @Autowired private MasterCategoryRepository masterCategoryRepository; @Autowired private UserRepository userRepository; @Test public void shouldSaveNewMaterCategories() {
User user = userRepository.save(new User().setName("Bob").setCurrency("€"));
BudgetFreak/BudgetFreak
server/user-management/src/test/java/de/budgetfreak/usermanagement/UserTestUtils.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import de.budgetfreak.usermanagement.domain.User; import java.util.Arrays; import java.util.List;
package de.budgetfreak.usermanagement; public class UserTestUtils { private UserTestUtils() { }
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/UserTestUtils.java import de.budgetfreak.usermanagement.domain.User; import java.util.Arrays; import java.util.List; package de.budgetfreak.usermanagement; public class UserTestUtils { private UserTestUtils() { }
public static List<User> createBobAndJane() {
BudgetFreak/BudgetFreak
server/user-management/src/test/java/de/budgetfreak/usermanagement/web/UserControllerUserLinksTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.hateoas.Link; import org.springframework.test.context.junit4.SpringRunner; import de.budgetfreak.usermanagement.domain.User;
package de.budgetfreak.usermanagement.web; @RunWith(SpringRunner.class) @WebMvcTest(value = UserControllerUserLinks.class) public class UserControllerUserLinksTest { @InjectMocks private UserControllerUserLinks testSubject; @Test public void generateLinks() { List<Link> links = new ArrayList<>(testSubject.generateLinks(createUser())); assertThat(links.size()).isEqualTo(2); assertThat(links.get(0).getRel()).isEqualTo("self"); assertThat(links.get(0).getHref()).isEqualTo("/users/1"); assertThat(links.get(1).getRel()).isEqualTo("users"); assertThat(links.get(1).getHref()).isEqualTo("/users"); }
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/user-management/src/test/java/de/budgetfreak/usermanagement/web/UserControllerUserLinksTest.java import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.hateoas.Link; import org.springframework.test.context.junit4.SpringRunner; import de.budgetfreak.usermanagement.domain.User; package de.budgetfreak.usermanagement.web; @RunWith(SpringRunner.class) @WebMvcTest(value = UserControllerUserLinks.class) public class UserControllerUserLinksTest { @InjectMocks private UserControllerUserLinks testSubject; @Test public void generateLinks() { List<Link> links = new ArrayList<>(testSubject.generateLinks(createUser())); assertThat(links.size()).isEqualTo(2); assertThat(links.get(0).getRel()).isEqualTo("self"); assertThat(links.get(0).getHref()).isEqualTo("/users/1"); assertThat(links.get(1).getRel()).isEqualTo("users"); assertThat(links.get(1).getHref()).isEqualTo("/users"); }
private User createUser() {
BudgetFreak/BudgetFreak
server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // }
import de.budgetfreak.usermanagement.domain.User; import javax.persistence.*;
package de.budgetfreak.accounting.domain; /** * Entity representing an account. */ @Entity(name = "BF_ACCOUNT") public class Account { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "DESCRIPTION") private String description; @Column(name = "ON_BUDGET") private boolean onBudget; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "USER_ID")
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java import de.budgetfreak.usermanagement.domain.User; import javax.persistence.*; package de.budgetfreak.accounting.domain; /** * Entity representing an account. */ @Entity(name = "BF_ACCOUNT") public class Account { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") private Long id; @Column(name = "DESCRIPTION") private String description; @Column(name = "ON_BUDGET") private boolean onBudget; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "USER_ID")
private User user;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/CategoryBudgetRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class CategoryBudgetRepositoryTest { @Autowired private CategoryBudgetRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired private BudgetRepository budgetRepository; @Autowired
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/CategoryBudgetRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class CategoryBudgetRepositoryTest { @Autowired private CategoryBudgetRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired private BudgetRepository budgetRepository; @Autowired
private UserRepository userRepository;
BudgetFreak/BudgetFreak
server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/CategoryBudgetRepositoryTest.java
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // }
import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat;
package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class CategoryBudgetRepositoryTest { @Autowired private CategoryBudgetRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired private BudgetRepository budgetRepository; @Autowired private UserRepository userRepository; @Autowired private MasterCategoryRepository masterCategoryRepository; @Test public void shouldSaveNewMaterCategories() {
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/User.java // @Entity(name = "BF_USER") // public class User { // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "ID") // private Long id; // // @Column(name = "NAME") // private String name; // // @Column(name = "CURRENCY") // private String currency; // // public User() { // } // // public User(String name, String currency) { // this.name = name; // this.currency = currency; // } // // public Long getId() { // return id; // } // // public User setId(Long id) { // this.id = id; // return this; // } // // public String getName() { // return name; // } // // public User setName(String name) { // this.name = name; // return this; // } // // public String getCurrency() { // return currency; // } // // public User setCurrency(String currency) { // this.currency = currency; // return this; // } // } // // Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/domain/UserRepository.java // @Repository // public interface UserRepository extends JpaRepository<User, Long> { // // User findByName(String name); // } // Path: server/budgeting/src/test/java/de/budgetfreak/budgeting/domain/CategoryBudgetRepositoryTest.java import de.budgetfreak.usermanagement.domain.User; import de.budgetfreak.usermanagement.domain.UserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; package de.budgetfreak.budgeting.domain; @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @EntityScan("de.budgetfreak") @EnableJpaRepositories("de.budgetfreak") public class CategoryBudgetRepositoryTest { @Autowired private CategoryBudgetRepository testSubject; @Autowired private CategoryRepository categoryRepository; @Autowired private BudgetRepository budgetRepository; @Autowired private UserRepository userRepository; @Autowired private MasterCategoryRepository masterCategoryRepository; @Test public void shouldSaveNewMaterCategories() {
User user = userRepository.save(new User().setName("Bob").setCurrency("€"));
google/ftc-object-detection
TFObjectDetector/tfod/src/main/java/com/google/ftcresearch/tfod/tracking/ObjectTracker.java
// Path: TFObjectDetector/tfod/src/main/java/com/google/ftcresearch/tfod/util/Size.java // public class Size implements Comparable<Size>, Serializable { // // // 1.4 went out with this UID so we'll need to maintain it to preserve pending queries when // // upgrading. // public static final long serialVersionUID = 7689808733290872361L; // // public final int width; // public final int height; // // public Size(final int width, final int height) { // this.width = width; // this.height = height; // } // // public Size(final Bitmap bmp) { // this.width = bmp.getWidth(); // this.height = bmp.getHeight(); // } // // /** // * Rotate a size by the given number of degrees. // * // * @param size Size to rotate. // * @param rotation Degrees {0, 90, 180, 270} to rotate the size. // * @return Rotated size. // */ // public static Size getRotatedSize(final Size size, final int rotation) { // if (rotation % 180 != 0) { // // The phone is portrait, therefore the camera is sideways and frame should be rotated. // return new Size(size.height, size.width); // } // return size; // } // // public static Size parseFromString(String sizeString) { // if (TextUtils.isEmpty(sizeString)) { // return null; // } // // sizeString = sizeString.trim(); // // // The expected format is "<width>x<height>". // final String[] components = sizeString.split("x"); // if (components.length == 2) { // try { // final int width = Integer.parseInt(components[0]); // final int height = Integer.parseInt(components[1]); // return new Size(width, height); // } catch (final NumberFormatException e) { // return null; // } // } else { // return null; // } // } // // public static List<Size> sizeStringToList(final String sizes) { // final List<Size> sizeList = new ArrayList<Size>(); // if (sizes != null) { // final String[] pairs = sizes.split(","); // for (final String pair : pairs) { // final Size size = Size.parseFromString(pair); // if (size != null) { // sizeList.add(size); // } // } // } // return sizeList; // } // // public static String sizeListToString(final List<Size> sizes) { // String sizesString = ""; // if (sizes != null && sizes.size() > 0) { // sizesString = sizes.get(0).toString(); // for (int i = 1; i < sizes.size(); i++) { // sizesString += "," + sizes.get(i).toString(); // } // } // return sizesString; // } // // public final float aspectRatio() { // return (float) width / (float) height; // } // // @Override // public int compareTo(final Size other) { // return width * height - other.width * other.height; // } // // @Override // public boolean equals(final Object other) { // if (other == null) { // return false; // } // // if (!(other instanceof Size)) { // return false; // } // // final Size otherSize = (Size) other; // return (width == otherSize.width && height == otherSize.height); // } // // @Override // public int hashCode() { // return width * 32713 + height; // } // // @Override // public String toString() { // return dimensionsAsString(width, height); // } // // public static final String dimensionsAsString(final int width, final int height) { // return width + "x" + height; // } // }
import javax.microedition.khronos.opengles.GL10; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PointF; import android.graphics.RectF; import android.graphics.Typeface; import android.util.Log; import com.google.ftcresearch.tfod.util.Size; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Vector;
this.frameWidth = frameWidth; this.frameHeight = frameHeight; this.rowStride = rowStride; this.alwaysTrack = alwaysTrack; this.timestampedDeltas = new LinkedList<TimestampedDeltas>(); trackedObjects = new HashMap<String, TrackedObject>(); debugHistory = new Vector<PointF>(MAX_DEBUG_HISTORY_SIZE); downsampledFrame = new byte [(frameWidth + DOWNSAMPLE_FACTOR - 1) / DOWNSAMPLE_FACTOR * (frameWidth + DOWNSAMPLE_FACTOR - 1) / DOWNSAMPLE_FACTOR]; } protected void init() { // The native tracker never sees the full frame, so pre-scale dimensions // by the downsample factor. initNative(frameWidth / DOWNSAMPLE_FACTOR, frameHeight / DOWNSAMPLE_FACTOR, alwaysTrack); } private final float[] matrixValues = new float[9]; private long downsampledTimestamp; @SuppressWarnings("unused") public synchronized void drawOverlay(
// Path: TFObjectDetector/tfod/src/main/java/com/google/ftcresearch/tfod/util/Size.java // public class Size implements Comparable<Size>, Serializable { // // // 1.4 went out with this UID so we'll need to maintain it to preserve pending queries when // // upgrading. // public static final long serialVersionUID = 7689808733290872361L; // // public final int width; // public final int height; // // public Size(final int width, final int height) { // this.width = width; // this.height = height; // } // // public Size(final Bitmap bmp) { // this.width = bmp.getWidth(); // this.height = bmp.getHeight(); // } // // /** // * Rotate a size by the given number of degrees. // * // * @param size Size to rotate. // * @param rotation Degrees {0, 90, 180, 270} to rotate the size. // * @return Rotated size. // */ // public static Size getRotatedSize(final Size size, final int rotation) { // if (rotation % 180 != 0) { // // The phone is portrait, therefore the camera is sideways and frame should be rotated. // return new Size(size.height, size.width); // } // return size; // } // // public static Size parseFromString(String sizeString) { // if (TextUtils.isEmpty(sizeString)) { // return null; // } // // sizeString = sizeString.trim(); // // // The expected format is "<width>x<height>". // final String[] components = sizeString.split("x"); // if (components.length == 2) { // try { // final int width = Integer.parseInt(components[0]); // final int height = Integer.parseInt(components[1]); // return new Size(width, height); // } catch (final NumberFormatException e) { // return null; // } // } else { // return null; // } // } // // public static List<Size> sizeStringToList(final String sizes) { // final List<Size> sizeList = new ArrayList<Size>(); // if (sizes != null) { // final String[] pairs = sizes.split(","); // for (final String pair : pairs) { // final Size size = Size.parseFromString(pair); // if (size != null) { // sizeList.add(size); // } // } // } // return sizeList; // } // // public static String sizeListToString(final List<Size> sizes) { // String sizesString = ""; // if (sizes != null && sizes.size() > 0) { // sizesString = sizes.get(0).toString(); // for (int i = 1; i < sizes.size(); i++) { // sizesString += "," + sizes.get(i).toString(); // } // } // return sizesString; // } // // public final float aspectRatio() { // return (float) width / (float) height; // } // // @Override // public int compareTo(final Size other) { // return width * height - other.width * other.height; // } // // @Override // public boolean equals(final Object other) { // if (other == null) { // return false; // } // // if (!(other instanceof Size)) { // return false; // } // // final Size otherSize = (Size) other; // return (width == otherSize.width && height == otherSize.height); // } // // @Override // public int hashCode() { // return width * 32713 + height; // } // // @Override // public String toString() { // return dimensionsAsString(width, height); // } // // public static final String dimensionsAsString(final int width, final int height) { // return width + "x" + height; // } // } // Path: TFObjectDetector/tfod/src/main/java/com/google/ftcresearch/tfod/tracking/ObjectTracker.java import javax.microedition.khronos.opengles.GL10; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PointF; import android.graphics.RectF; import android.graphics.Typeface; import android.util.Log; import com.google.ftcresearch.tfod.util.Size; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Vector; this.frameWidth = frameWidth; this.frameHeight = frameHeight; this.rowStride = rowStride; this.alwaysTrack = alwaysTrack; this.timestampedDeltas = new LinkedList<TimestampedDeltas>(); trackedObjects = new HashMap<String, TrackedObject>(); debugHistory = new Vector<PointF>(MAX_DEBUG_HISTORY_SIZE); downsampledFrame = new byte [(frameWidth + DOWNSAMPLE_FACTOR - 1) / DOWNSAMPLE_FACTOR * (frameWidth + DOWNSAMPLE_FACTOR - 1) / DOWNSAMPLE_FACTOR]; } protected void init() { // The native tracker never sees the full frame, so pre-scale dimensions // by the downsample factor. initNative(frameWidth / DOWNSAMPLE_FACTOR, frameHeight / DOWNSAMPLE_FACTOR, alwaysTrack); } private final float[] matrixValues = new float[9]; private long downsampledTimestamp; @SuppressWarnings("unused") public synchronized void drawOverlay(
final GL10 gl, final Size cameraViewSize, final Matrix matrix) {
google/ftc-object-detection
TFObjectDetector/tfod/src/test/java/com/google/ftcresearch/tfod/RollingAverageTest.java
// Path: TFObjectDetector/tfod/src/main/java/com/google/ftcresearch/tfod/util/RollingAverage.java // public class RollingAverage { // // /** Each of the elements, maintained as a ring buffer. */ // private final double[] elements; // // /** How many elements we have stored in the elements array. */ // private int numElements; // // /** The index into elements of the first available slot (oldest element). */ // private int elementsIndex; // // /** The sum for all valid elements inside elements. */ // private double sum; // // /** The actual current average. */ // // Volatile keyword ensures that updates are atomic and seen by all threads. // private volatile double average; // // /** // * Construct a new RollingAverage which will start at a specific value, rather than 0. // * // * @param bufferSize The number of elements to keep a rolling average over. // * @param startingValue The value to return from get() if add() has not been called. // */ // public RollingAverage(int bufferSize, double startingValue) { // // if (bufferSize <= 0) { // throw new IllegalArgumentException("Need positive buffer size!"); // } // // this.average = startingValue; // elements = new double[bufferSize]; // } // // /** // * Construct a new RollingAverage which will start at 0. // * // * @param bufferSize The number of elements to keep a rolling average over. // */ // public RollingAverage(int bufferSize) { // this(bufferSize, 0); // Default starting value of 0. // } // // public double get() { // // Just returning average is fine, as long as there's never a chance of it being in an // // inconsistent state inside the add() method. // return average; // } // // public synchronized void add(double value) { // // // First, see if space needs to be made for the new value. // numElements++; // // if (numElements > elements.length) { // double removeValue = elements[elementsIndex]; // numElements = elements.length; // sum -= removeValue; // Remove the evicted value from the sum. // } // // // Then, store the value we just got. // elements[elementsIndex] = value; // elementsIndex = (elementsIndex + 1) % elements.length; // // // Finally, add the new value into the sum and compute the new average. // sum += value; // average = sum / numElements; // Write to volatile double is atomic // } // }
import com.google.ftcresearch.tfod.util.RollingAverage; import org.junit.Test; import java.util.LinkedList; import java.util.List; import static org.junit.Assert.assertEquals;
/* * Copyright (C) 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.ftcresearch.tfod; public class RollingAverageTest { private static final double ALLOWABLE_DELTA = 1e-5; @Test public void returnsDefault() {
// Path: TFObjectDetector/tfod/src/main/java/com/google/ftcresearch/tfod/util/RollingAverage.java // public class RollingAverage { // // /** Each of the elements, maintained as a ring buffer. */ // private final double[] elements; // // /** How many elements we have stored in the elements array. */ // private int numElements; // // /** The index into elements of the first available slot (oldest element). */ // private int elementsIndex; // // /** The sum for all valid elements inside elements. */ // private double sum; // // /** The actual current average. */ // // Volatile keyword ensures that updates are atomic and seen by all threads. // private volatile double average; // // /** // * Construct a new RollingAverage which will start at a specific value, rather than 0. // * // * @param bufferSize The number of elements to keep a rolling average over. // * @param startingValue The value to return from get() if add() has not been called. // */ // public RollingAverage(int bufferSize, double startingValue) { // // if (bufferSize <= 0) { // throw new IllegalArgumentException("Need positive buffer size!"); // } // // this.average = startingValue; // elements = new double[bufferSize]; // } // // /** // * Construct a new RollingAverage which will start at 0. // * // * @param bufferSize The number of elements to keep a rolling average over. // */ // public RollingAverage(int bufferSize) { // this(bufferSize, 0); // Default starting value of 0. // } // // public double get() { // // Just returning average is fine, as long as there's never a chance of it being in an // // inconsistent state inside the add() method. // return average; // } // // public synchronized void add(double value) { // // // First, see if space needs to be made for the new value. // numElements++; // // if (numElements > elements.length) { // double removeValue = elements[elementsIndex]; // numElements = elements.length; // sum -= removeValue; // Remove the evicted value from the sum. // } // // // Then, store the value we just got. // elements[elementsIndex] = value; // elementsIndex = (elementsIndex + 1) % elements.length; // // // Finally, add the new value into the sum and compute the new average. // sum += value; // average = sum / numElements; // Write to volatile double is atomic // } // } // Path: TFObjectDetector/tfod/src/test/java/com/google/ftcresearch/tfod/RollingAverageTest.java import com.google.ftcresearch.tfod.util.RollingAverage; import org.junit.Test; import java.util.LinkedList; import java.util.List; import static org.junit.Assert.assertEquals; /* * Copyright (C) 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.ftcresearch.tfod; public class RollingAverageTest { private static final double ALLOWABLE_DELTA = 1e-5; @Test public void returnsDefault() {
RollingAverage average;
vert-x3/vertx-kafka-client
src/test/java/io/vertx/kafka/client/tests/KafkaHeaderTest.java
// Path: src/main/java/io/vertx/kafka/client/producer/KafkaHeader.java // @VertxGen // public interface KafkaHeader { // // static KafkaHeader header(String key, Buffer value) { // return new KafkaHeaderImpl(key, value); // } // // static KafkaHeader header(String key, String value) { // return new KafkaHeaderImpl(key, value); // } // // @GenIgnore // static KafkaHeader header(String key, byte[] value) { // return new KafkaHeaderImpl(key, Buffer.buffer(value)); // } // // /** // * @return the buffer key // */ // @CacheReturn // String key(); // // /** // * @return the buffer value // */ // @CacheReturn // Buffer value(); // // } // // Path: src/main/java/io/vertx/kafka/client/producer/KafkaProducerRecord.java // @VertxGen // public interface KafkaProducerRecord<K, V> { // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param timestamp the timestamp of this record // * @param partition the partition to which the record will be sent (or null if no partition was specified) // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Long timestamp, Integer partition) { // // return new KafkaProducerRecordImpl<>(topic, key, value, timestamp, partition); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param partition the partition to which the record will be sent (or null if no partition was specified) // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // @GenIgnore // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Integer partition) { // // return new KafkaProducerRecordImpl<>(topic, key, value, partition); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value) { // // return new KafkaProducerRecordImpl<>(topic, key, value); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param value the value // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, V value) { // // return new KafkaProducerRecordImpl<>(topic, value); // } // // /** // * @return the topic this record is being sent to // */ // String topic(); // // /** // * @return the key (or null if no key is specified) // */ // K key(); // // /** // * @return the value // */ // V value(); // // /** // * @return the timestamp of this record // */ // Long timestamp(); // // /** // * @return the partition to which the record will be sent (or null if no partition was specified) // */ // Integer partition(); // // /** // * Like {@link #addHeader(KafkaHeader)} but with a key/value pair // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(String key, String value); // // /** // * Like {@link #addHeader(KafkaHeader)} but with a key/value pair // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(String key, Buffer value); // // /** // * Add an header to this record. // * // * @param header the header // * @return current KafkaProducerRecord instance // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(KafkaHeader header); // // /** // * Add a list of headers to this record. // * // * @param headers the headers // * @return current KafkaProducerRecord instance // */ // @Fluent // KafkaProducerRecord<K, V> addHeaders(List<KafkaHeader> headers); // // /** // * @return the headers of this record // */ // @CacheReturn // List<KafkaHeader> headers(); // // /** // * @return a created native Kafka producer record with backed information // */ // @GenIgnore // ProducerRecord<K, V> record(); // // }
import io.vertx.kafka.client.producer.KafkaHeader; import io.vertx.kafka.client.producer.KafkaProducerRecord; import org.junit.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull;
/* * Copyright 2018 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.tests; public class KafkaHeaderTest { @Test public void testEmptyHeaders() {
// Path: src/main/java/io/vertx/kafka/client/producer/KafkaHeader.java // @VertxGen // public interface KafkaHeader { // // static KafkaHeader header(String key, Buffer value) { // return new KafkaHeaderImpl(key, value); // } // // static KafkaHeader header(String key, String value) { // return new KafkaHeaderImpl(key, value); // } // // @GenIgnore // static KafkaHeader header(String key, byte[] value) { // return new KafkaHeaderImpl(key, Buffer.buffer(value)); // } // // /** // * @return the buffer key // */ // @CacheReturn // String key(); // // /** // * @return the buffer value // */ // @CacheReturn // Buffer value(); // // } // // Path: src/main/java/io/vertx/kafka/client/producer/KafkaProducerRecord.java // @VertxGen // public interface KafkaProducerRecord<K, V> { // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param timestamp the timestamp of this record // * @param partition the partition to which the record will be sent (or null if no partition was specified) // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Long timestamp, Integer partition) { // // return new KafkaProducerRecordImpl<>(topic, key, value, timestamp, partition); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param partition the partition to which the record will be sent (or null if no partition was specified) // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // @GenIgnore // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Integer partition) { // // return new KafkaProducerRecordImpl<>(topic, key, value, partition); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value) { // // return new KafkaProducerRecordImpl<>(topic, key, value); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param value the value // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, V value) { // // return new KafkaProducerRecordImpl<>(topic, value); // } // // /** // * @return the topic this record is being sent to // */ // String topic(); // // /** // * @return the key (or null if no key is specified) // */ // K key(); // // /** // * @return the value // */ // V value(); // // /** // * @return the timestamp of this record // */ // Long timestamp(); // // /** // * @return the partition to which the record will be sent (or null if no partition was specified) // */ // Integer partition(); // // /** // * Like {@link #addHeader(KafkaHeader)} but with a key/value pair // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(String key, String value); // // /** // * Like {@link #addHeader(KafkaHeader)} but with a key/value pair // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(String key, Buffer value); // // /** // * Add an header to this record. // * // * @param header the header // * @return current KafkaProducerRecord instance // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(KafkaHeader header); // // /** // * Add a list of headers to this record. // * // * @param headers the headers // * @return current KafkaProducerRecord instance // */ // @Fluent // KafkaProducerRecord<K, V> addHeaders(List<KafkaHeader> headers); // // /** // * @return the headers of this record // */ // @CacheReturn // List<KafkaHeader> headers(); // // /** // * @return a created native Kafka producer record with backed information // */ // @GenIgnore // ProducerRecord<K, V> record(); // // } // Path: src/test/java/io/vertx/kafka/client/tests/KafkaHeaderTest.java import io.vertx.kafka.client.producer.KafkaHeader; import io.vertx.kafka.client.producer.KafkaProducerRecord; import org.junit.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; /* * Copyright 2018 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.tests; public class KafkaHeaderTest { @Test public void testEmptyHeaders() {
List<KafkaHeader> kafkaHeaders = KafkaProducerRecord.create("topic", "key", "value").headers();
vert-x3/vertx-kafka-client
src/test/java/io/vertx/kafka/client/tests/KafkaHeaderTest.java
// Path: src/main/java/io/vertx/kafka/client/producer/KafkaHeader.java // @VertxGen // public interface KafkaHeader { // // static KafkaHeader header(String key, Buffer value) { // return new KafkaHeaderImpl(key, value); // } // // static KafkaHeader header(String key, String value) { // return new KafkaHeaderImpl(key, value); // } // // @GenIgnore // static KafkaHeader header(String key, byte[] value) { // return new KafkaHeaderImpl(key, Buffer.buffer(value)); // } // // /** // * @return the buffer key // */ // @CacheReturn // String key(); // // /** // * @return the buffer value // */ // @CacheReturn // Buffer value(); // // } // // Path: src/main/java/io/vertx/kafka/client/producer/KafkaProducerRecord.java // @VertxGen // public interface KafkaProducerRecord<K, V> { // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param timestamp the timestamp of this record // * @param partition the partition to which the record will be sent (or null if no partition was specified) // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Long timestamp, Integer partition) { // // return new KafkaProducerRecordImpl<>(topic, key, value, timestamp, partition); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param partition the partition to which the record will be sent (or null if no partition was specified) // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // @GenIgnore // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Integer partition) { // // return new KafkaProducerRecordImpl<>(topic, key, value, partition); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value) { // // return new KafkaProducerRecordImpl<>(topic, key, value); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param value the value // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, V value) { // // return new KafkaProducerRecordImpl<>(topic, value); // } // // /** // * @return the topic this record is being sent to // */ // String topic(); // // /** // * @return the key (or null if no key is specified) // */ // K key(); // // /** // * @return the value // */ // V value(); // // /** // * @return the timestamp of this record // */ // Long timestamp(); // // /** // * @return the partition to which the record will be sent (or null if no partition was specified) // */ // Integer partition(); // // /** // * Like {@link #addHeader(KafkaHeader)} but with a key/value pair // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(String key, String value); // // /** // * Like {@link #addHeader(KafkaHeader)} but with a key/value pair // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(String key, Buffer value); // // /** // * Add an header to this record. // * // * @param header the header // * @return current KafkaProducerRecord instance // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(KafkaHeader header); // // /** // * Add a list of headers to this record. // * // * @param headers the headers // * @return current KafkaProducerRecord instance // */ // @Fluent // KafkaProducerRecord<K, V> addHeaders(List<KafkaHeader> headers); // // /** // * @return the headers of this record // */ // @CacheReturn // List<KafkaHeader> headers(); // // /** // * @return a created native Kafka producer record with backed information // */ // @GenIgnore // ProducerRecord<K, V> record(); // // }
import io.vertx.kafka.client.producer.KafkaHeader; import io.vertx.kafka.client.producer.KafkaProducerRecord; import org.junit.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull;
/* * Copyright 2018 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.tests; public class KafkaHeaderTest { @Test public void testEmptyHeaders() {
// Path: src/main/java/io/vertx/kafka/client/producer/KafkaHeader.java // @VertxGen // public interface KafkaHeader { // // static KafkaHeader header(String key, Buffer value) { // return new KafkaHeaderImpl(key, value); // } // // static KafkaHeader header(String key, String value) { // return new KafkaHeaderImpl(key, value); // } // // @GenIgnore // static KafkaHeader header(String key, byte[] value) { // return new KafkaHeaderImpl(key, Buffer.buffer(value)); // } // // /** // * @return the buffer key // */ // @CacheReturn // String key(); // // /** // * @return the buffer value // */ // @CacheReturn // Buffer value(); // // } // // Path: src/main/java/io/vertx/kafka/client/producer/KafkaProducerRecord.java // @VertxGen // public interface KafkaProducerRecord<K, V> { // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param timestamp the timestamp of this record // * @param partition the partition to which the record will be sent (or null if no partition was specified) // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Long timestamp, Integer partition) { // // return new KafkaProducerRecordImpl<>(topic, key, value, timestamp, partition); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param partition the partition to which the record will be sent (or null if no partition was specified) // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // @GenIgnore // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Integer partition) { // // return new KafkaProducerRecordImpl<>(topic, key, value, partition); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value) { // // return new KafkaProducerRecordImpl<>(topic, key, value); // } // // /** // * Create a concrete instance of a Vert.x producer record // * // * @param topic the topic this record is being sent to // * @param value the value // * @param <K> key type // * @param <V> value type // * @return Vert.x producer record // */ // static <K, V> KafkaProducerRecord<K, V> create(String topic, V value) { // // return new KafkaProducerRecordImpl<>(topic, value); // } // // /** // * @return the topic this record is being sent to // */ // String topic(); // // /** // * @return the key (or null if no key is specified) // */ // K key(); // // /** // * @return the value // */ // V value(); // // /** // * @return the timestamp of this record // */ // Long timestamp(); // // /** // * @return the partition to which the record will be sent (or null if no partition was specified) // */ // Integer partition(); // // /** // * Like {@link #addHeader(KafkaHeader)} but with a key/value pair // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(String key, String value); // // /** // * Like {@link #addHeader(KafkaHeader)} but with a key/value pair // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(String key, Buffer value); // // /** // * Add an header to this record. // * // * @param header the header // * @return current KafkaProducerRecord instance // */ // @Fluent // KafkaProducerRecord<K, V> addHeader(KafkaHeader header); // // /** // * Add a list of headers to this record. // * // * @param headers the headers // * @return current KafkaProducerRecord instance // */ // @Fluent // KafkaProducerRecord<K, V> addHeaders(List<KafkaHeader> headers); // // /** // * @return the headers of this record // */ // @CacheReturn // List<KafkaHeader> headers(); // // /** // * @return a created native Kafka producer record with backed information // */ // @GenIgnore // ProducerRecord<K, V> record(); // // } // Path: src/test/java/io/vertx/kafka/client/tests/KafkaHeaderTest.java import io.vertx.kafka.client.producer.KafkaHeader; import io.vertx.kafka.client.producer.KafkaProducerRecord; import org.junit.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; /* * Copyright 2018 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.tests; public class KafkaHeaderTest { @Test public void testEmptyHeaders() {
List<KafkaHeader> kafkaHeaders = KafkaProducerRecord.create("topic", "key", "value").headers();
vert-x3/vertx-kafka-client
src/main/java/io/vertx/kafka/client/producer/KafkaHeader.java
// Path: src/main/java/io/vertx/kafka/client/producer/impl/KafkaHeaderImpl.java // public class KafkaHeaderImpl implements KafkaHeader { // // private String key; // private Buffer value; // // public KafkaHeaderImpl(String key, Buffer value) { // this.key = key; // this.value = value; // } // // public KafkaHeaderImpl(String key, String value) { // this(key, Buffer.buffer(value)); // } // // @Override // public String key() { // return key; // } // // @Override // public Buffer value() { // return value; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // KafkaHeaderImpl that = (KafkaHeaderImpl) o; // return Objects.equals(key, that.key) && Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // // @Override // public String toString() { // return "KafkaHeaderImpl{'" + key + "': " + value + '}'; // } // // }
import io.vertx.codegen.annotations.CacheReturn; import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.VertxGen; import io.vertx.core.buffer.Buffer; import io.vertx.kafka.client.producer.impl.KafkaHeaderImpl;
/* * Copyright 2018 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.producer; /** * Vert.x Kafka producer record header. */ @VertxGen public interface KafkaHeader { static KafkaHeader header(String key, Buffer value) {
// Path: src/main/java/io/vertx/kafka/client/producer/impl/KafkaHeaderImpl.java // public class KafkaHeaderImpl implements KafkaHeader { // // private String key; // private Buffer value; // // public KafkaHeaderImpl(String key, Buffer value) { // this.key = key; // this.value = value; // } // // public KafkaHeaderImpl(String key, String value) { // this(key, Buffer.buffer(value)); // } // // @Override // public String key() { // return key; // } // // @Override // public Buffer value() { // return value; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // KafkaHeaderImpl that = (KafkaHeaderImpl) o; // return Objects.equals(key, that.key) && Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // // @Override // public String toString() { // return "KafkaHeaderImpl{'" + key + "': " + value + '}'; // } // // } // Path: src/main/java/io/vertx/kafka/client/producer/KafkaHeader.java import io.vertx.codegen.annotations.CacheReturn; import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.VertxGen; import io.vertx.core.buffer.Buffer; import io.vertx.kafka.client.producer.impl.KafkaHeaderImpl; /* * Copyright 2018 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.producer; /** * Vert.x Kafka producer record header. */ @VertxGen public interface KafkaHeader { static KafkaHeader header(String key, Buffer value) {
return new KafkaHeaderImpl(key, value);
vert-x3/vertx-kafka-client
src/main/java/io/vertx/kafka/client/common/tracing/ConsumerTracer.java
// Path: src/main/java/io/vertx/kafka/client/common/KafkaClientOptions.java // @DataObject(generateConverter = true) // public class KafkaClientOptions { // /** // * Default peer address to set in traces tags is null, and will automatically pick up bootstrap server from config // */ // public static final String DEFAULT_TRACE_PEER_ADDRESS = null; // // /** // * Default tracing policy is 'propagate' // */ // public static final TracingPolicy DEFAULT_TRACING_POLICY = TracingPolicy.PROPAGATE; // // private Map<String, Object> config; // private String tracePeerAddress = DEFAULT_TRACE_PEER_ADDRESS; // private TracingPolicy tracingPolicy = DEFAULT_TRACING_POLICY; // // public KafkaClientOptions() { // } // // public KafkaClientOptions(JsonObject json) { // this(); // KafkaClientOptionsConverter.fromJson(json, this); // } // // /** // * Create KafkaClientOptions from underlying Kafka config as map // * @param config config map to be passed down to underlying Kafka client // * @return an instance of KafkaClientOptions // */ // public static KafkaClientOptions fromMap(Map<String, Object> config, boolean isProducer) { // String tracePeerAddress = (String) config.getOrDefault(isProducer ? ProducerConfig.BOOTSTRAP_SERVERS_CONFIG : ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, ""); // return new KafkaClientOptions().setTracePeerAddress(tracePeerAddress); // } // // /** // * Create KafkaClientOptions from underlying Kafka config as Properties // * @param config config properties to be passed down to underlying Kafka client // * @return an instance of KafkaClientOptions // */ // public static KafkaClientOptions fromProperties(Properties config, boolean isProducer) { // String tracePeerAddress = (String) config.getOrDefault(isProducer ? ProducerConfig.BOOTSTRAP_SERVERS_CONFIG : ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, ""); // return new KafkaClientOptions().setTracePeerAddress(tracePeerAddress); // } // // /** // * @return the kafka config // */ // public Map<String, Object> getConfig() { // return config; // } // // /** // * Set the Kafka config. // * // * @param config the config // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setConfig(Map<String, Object> config) { // this.config = config; // return this; // } // // /** // * Set a Kafka config entry. // * // * @param key the config key // * @param value the config value // * @return a reference to this, so the API can be used fluently // */ // @GenIgnore // public KafkaClientOptions setConfig(String key, Object value) { // if (config == null) { // config = new HashMap<>(); // } // config.put(key, value); // return this; // } // // /** // * @return the kafka tracing policy // */ // public TracingPolicy getTracingPolicy() { // return tracingPolicy; // } // // /** // * Set the Kafka tracing policy. // * // * @param tracingPolicy the tracing policy // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setTracingPolicy(TracingPolicy tracingPolicy) { // this.tracingPolicy = tracingPolicy; // return this; // } // // /** // * @return the Kafka "peer address" to show in trace tags // */ // public String getTracePeerAddress() { // return tracePeerAddress; // } // // /** // * Set the Kafka address to show in trace tags. // * Or leave it unset to automatically pick up bootstrap server from config instead. // * // * @param tracePeerAddress the Kafka "peer address" to show in trace tags // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setTracePeerAddress(String tracePeerAddress) { // this.tracePeerAddress = tracePeerAddress; // return this; // } // // public JsonObject toJson() { // return new JsonObject(); // } // }
import io.vertx.core.Context; import io.vertx.core.spi.tracing.SpanKind; import io.vertx.core.spi.tracing.TagExtractor; import io.vertx.core.spi.tracing.VertxTracer; import io.vertx.core.tracing.TracingPolicy; import io.vertx.kafka.client.common.KafkaClientOptions; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.header.Headers; import org.apache.kafka.common.utils.Utils; import java.util.AbstractMap; import java.util.Collections; import java.util.Map; import java.util.stream.StreamSupport;
/* * Copyright 2020 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.common.tracing; /** * Tracer for Kafka consumer, wrapping the generic tracer. */ public class ConsumerTracer<S> { private final VertxTracer<S, Void> tracer; private final String address; private final String hostname; private final String port; private final TracingPolicy policy; /** * Creates a ConsumerTracer, which provides an opinionated facade for using {@link io.vertx.core.spi.tracing.VertxTracer} * with a Kafka Consumer use case. * The method will return {@code null} if Tracing is not setup in Vert.x, or if {@code TracingPolicy.IGNORE} is used. * @param tracer the generic tracer object * @param opts Kafka client options * @param <S> the type of spans that is going to be generated, depending on the tracing system (zipkin, opentracing ...) * @return a new instance of {@code ConsumerTracer}, or {@code null} */
// Path: src/main/java/io/vertx/kafka/client/common/KafkaClientOptions.java // @DataObject(generateConverter = true) // public class KafkaClientOptions { // /** // * Default peer address to set in traces tags is null, and will automatically pick up bootstrap server from config // */ // public static final String DEFAULT_TRACE_PEER_ADDRESS = null; // // /** // * Default tracing policy is 'propagate' // */ // public static final TracingPolicy DEFAULT_TRACING_POLICY = TracingPolicy.PROPAGATE; // // private Map<String, Object> config; // private String tracePeerAddress = DEFAULT_TRACE_PEER_ADDRESS; // private TracingPolicy tracingPolicy = DEFAULT_TRACING_POLICY; // // public KafkaClientOptions() { // } // // public KafkaClientOptions(JsonObject json) { // this(); // KafkaClientOptionsConverter.fromJson(json, this); // } // // /** // * Create KafkaClientOptions from underlying Kafka config as map // * @param config config map to be passed down to underlying Kafka client // * @return an instance of KafkaClientOptions // */ // public static KafkaClientOptions fromMap(Map<String, Object> config, boolean isProducer) { // String tracePeerAddress = (String) config.getOrDefault(isProducer ? ProducerConfig.BOOTSTRAP_SERVERS_CONFIG : ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, ""); // return new KafkaClientOptions().setTracePeerAddress(tracePeerAddress); // } // // /** // * Create KafkaClientOptions from underlying Kafka config as Properties // * @param config config properties to be passed down to underlying Kafka client // * @return an instance of KafkaClientOptions // */ // public static KafkaClientOptions fromProperties(Properties config, boolean isProducer) { // String tracePeerAddress = (String) config.getOrDefault(isProducer ? ProducerConfig.BOOTSTRAP_SERVERS_CONFIG : ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, ""); // return new KafkaClientOptions().setTracePeerAddress(tracePeerAddress); // } // // /** // * @return the kafka config // */ // public Map<String, Object> getConfig() { // return config; // } // // /** // * Set the Kafka config. // * // * @param config the config // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setConfig(Map<String, Object> config) { // this.config = config; // return this; // } // // /** // * Set a Kafka config entry. // * // * @param key the config key // * @param value the config value // * @return a reference to this, so the API can be used fluently // */ // @GenIgnore // public KafkaClientOptions setConfig(String key, Object value) { // if (config == null) { // config = new HashMap<>(); // } // config.put(key, value); // return this; // } // // /** // * @return the kafka tracing policy // */ // public TracingPolicy getTracingPolicy() { // return tracingPolicy; // } // // /** // * Set the Kafka tracing policy. // * // * @param tracingPolicy the tracing policy // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setTracingPolicy(TracingPolicy tracingPolicy) { // this.tracingPolicy = tracingPolicy; // return this; // } // // /** // * @return the Kafka "peer address" to show in trace tags // */ // public String getTracePeerAddress() { // return tracePeerAddress; // } // // /** // * Set the Kafka address to show in trace tags. // * Or leave it unset to automatically pick up bootstrap server from config instead. // * // * @param tracePeerAddress the Kafka "peer address" to show in trace tags // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setTracePeerAddress(String tracePeerAddress) { // this.tracePeerAddress = tracePeerAddress; // return this; // } // // public JsonObject toJson() { // return new JsonObject(); // } // } // Path: src/main/java/io/vertx/kafka/client/common/tracing/ConsumerTracer.java import io.vertx.core.Context; import io.vertx.core.spi.tracing.SpanKind; import io.vertx.core.spi.tracing.TagExtractor; import io.vertx.core.spi.tracing.VertxTracer; import io.vertx.core.tracing.TracingPolicy; import io.vertx.kafka.client.common.KafkaClientOptions; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.header.Headers; import org.apache.kafka.common.utils.Utils; import java.util.AbstractMap; import java.util.Collections; import java.util.Map; import java.util.stream.StreamSupport; /* * Copyright 2020 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.common.tracing; /** * Tracer for Kafka consumer, wrapping the generic tracer. */ public class ConsumerTracer<S> { private final VertxTracer<S, Void> tracer; private final String address; private final String hostname; private final String port; private final TracingPolicy policy; /** * Creates a ConsumerTracer, which provides an opinionated facade for using {@link io.vertx.core.spi.tracing.VertxTracer} * with a Kafka Consumer use case. * The method will return {@code null} if Tracing is not setup in Vert.x, or if {@code TracingPolicy.IGNORE} is used. * @param tracer the generic tracer object * @param opts Kafka client options * @param <S> the type of spans that is going to be generated, depending on the tracing system (zipkin, opentracing ...) * @return a new instance of {@code ConsumerTracer}, or {@code null} */
public static <S> ConsumerTracer create(VertxTracer tracer, KafkaClientOptions opts) {
vert-x3/vertx-kafka-client
src/main/java/io/vertx/kafka/admin/TopicDescription.java
// Path: src/main/java/io/vertx/kafka/client/common/TopicPartitionInfo.java // @DataObject(generateConverter = true) // public class TopicPartitionInfo { // // private List<Node> isr; // private Node leader; // private int partition; // private List<Node> replicas; // // /** // * Constructor // */ // public TopicPartitionInfo() { // // } // // /** // * Constructor // * // * @param isr the subset of the replicas that are in sync // * @param leader the node id of the node currently acting as a leader // * @param partition the partition id // * @param replicas the complete set of replicas for this partition // */ // public TopicPartitionInfo(List<Node> isr, Node leader, int partition, List<Node> replicas) { // this.isr = isr; // this.leader = leader; // this.partition = partition; // this.replicas = replicas; // } // // /** // * Constructor (from JSON representation) // * // * @param json JSON representation // */ // public TopicPartitionInfo(JsonObject json) { // // TopicPartitionInfoConverter.fromJson(json, this); // } // // /** // * @return the subset of the replicas that are in sync, that is caught-up to the leader and ready to take over as leader if the leader should fail // */ // public List<Node> getIsr() { // return this.isr; // } // // /** // * Set the subset of the replicas that are in sync // * // * @param isr the subset of the replicas that are in sync // * @return current instance of the class to be fluent // */ // public TopicPartitionInfo setIsr(List<Node> isr) { // this.isr = isr; // return this; // } // // /** // * @return the node id of the node currently acting as a leader for this partition or null if there is no leader // */ // public Node getLeader() { // return this.leader; // } // // /** // * Set the node id of the node currently acting as a leader // * // * @param leader the node id of the node currently acting as a leader // * @return current instance of the class to be fluent // */ // public TopicPartitionInfo setLeader(Node leader) { // this.leader = leader; // return this; // } // // /** // * @return the partition id // */ // public int getPartition() { // return this.partition; // } // // /** // * Set the partition id // * // * @param partition the partition id // * @return current instance of the class to be fluent // */ // public TopicPartitionInfo setPartition(int partition) { // this.partition = partition; // return this; // } // // /** // * @return the complete set of replicas for this partition regardless of whether they are alive or up-to-date // */ // public List<Node> getReplicas() { // return this.replicas; // } // // /** // * Set the complete set of replicas for this partition // * // * @param replicas the complete set of replicas for this partition // * @return current instance of the class to be fluent // */ // public TopicPartitionInfo setReplicas(List<Node> replicas) { // this.replicas = replicas; // return this; // } // // /** // * Convert object to JSON representation // * // * @return JSON representation // */ // public JsonObject toJson() { // // JsonObject json = new JsonObject(); // TopicPartitionInfoConverter.toJson(this, json); // return json; // } // // @Override // public String toString() { // // return "PartitionInfo{" + // "partition=" + this.partition + // ", isr=" + this.isr + // ", leader=" + this.leader + // ", replicas=" + this.replicas + // "}"; // } // }
import io.vertx.codegen.annotations.DataObject; import io.vertx.core.json.JsonObject; import io.vertx.kafka.client.common.TopicPartitionInfo; import java.util.List;
/* * Copyright 2019 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.admin; /** * A detailed description of a single topic in the cluster */ @DataObject(generateConverter = true) public class TopicDescription { private boolean isInternal; private String name;
// Path: src/main/java/io/vertx/kafka/client/common/TopicPartitionInfo.java // @DataObject(generateConverter = true) // public class TopicPartitionInfo { // // private List<Node> isr; // private Node leader; // private int partition; // private List<Node> replicas; // // /** // * Constructor // */ // public TopicPartitionInfo() { // // } // // /** // * Constructor // * // * @param isr the subset of the replicas that are in sync // * @param leader the node id of the node currently acting as a leader // * @param partition the partition id // * @param replicas the complete set of replicas for this partition // */ // public TopicPartitionInfo(List<Node> isr, Node leader, int partition, List<Node> replicas) { // this.isr = isr; // this.leader = leader; // this.partition = partition; // this.replicas = replicas; // } // // /** // * Constructor (from JSON representation) // * // * @param json JSON representation // */ // public TopicPartitionInfo(JsonObject json) { // // TopicPartitionInfoConverter.fromJson(json, this); // } // // /** // * @return the subset of the replicas that are in sync, that is caught-up to the leader and ready to take over as leader if the leader should fail // */ // public List<Node> getIsr() { // return this.isr; // } // // /** // * Set the subset of the replicas that are in sync // * // * @param isr the subset of the replicas that are in sync // * @return current instance of the class to be fluent // */ // public TopicPartitionInfo setIsr(List<Node> isr) { // this.isr = isr; // return this; // } // // /** // * @return the node id of the node currently acting as a leader for this partition or null if there is no leader // */ // public Node getLeader() { // return this.leader; // } // // /** // * Set the node id of the node currently acting as a leader // * // * @param leader the node id of the node currently acting as a leader // * @return current instance of the class to be fluent // */ // public TopicPartitionInfo setLeader(Node leader) { // this.leader = leader; // return this; // } // // /** // * @return the partition id // */ // public int getPartition() { // return this.partition; // } // // /** // * Set the partition id // * // * @param partition the partition id // * @return current instance of the class to be fluent // */ // public TopicPartitionInfo setPartition(int partition) { // this.partition = partition; // return this; // } // // /** // * @return the complete set of replicas for this partition regardless of whether they are alive or up-to-date // */ // public List<Node> getReplicas() { // return this.replicas; // } // // /** // * Set the complete set of replicas for this partition // * // * @param replicas the complete set of replicas for this partition // * @return current instance of the class to be fluent // */ // public TopicPartitionInfo setReplicas(List<Node> replicas) { // this.replicas = replicas; // return this; // } // // /** // * Convert object to JSON representation // * // * @return JSON representation // */ // public JsonObject toJson() { // // JsonObject json = new JsonObject(); // TopicPartitionInfoConverter.toJson(this, json); // return json; // } // // @Override // public String toString() { // // return "PartitionInfo{" + // "partition=" + this.partition + // ", isr=" + this.isr + // ", leader=" + this.leader + // ", replicas=" + this.replicas + // "}"; // } // } // Path: src/main/java/io/vertx/kafka/admin/TopicDescription.java import io.vertx.codegen.annotations.DataObject; import io.vertx.core.json.JsonObject; import io.vertx.kafka.client.common.TopicPartitionInfo; import java.util.List; /* * Copyright 2019 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.admin; /** * A detailed description of a single topic in the cluster */ @DataObject(generateConverter = true) public class TopicDescription { private boolean isInternal; private String name;
private List<TopicPartitionInfo> partitions;
vert-x3/vertx-kafka-client
src/main/java/io/vertx/kafka/admin/MemberAssignment.java
// Path: src/main/java/io/vertx/kafka/client/common/TopicPartition.java // @DataObject // public class TopicPartition { // // private String topic; // private int partition; // // /** // * Constructor // */ // public TopicPartition() { // } // // /** // * Constructor // * // * @param topic the topic name // * @param partition the partition number // */ // public TopicPartition(String topic, int partition) { // this.topic = topic; // this.partition = partition; // } // // /** // * Constructor (from JSON representation) // * // * @param json JSON representation // */ // public TopicPartition(JsonObject json) { // this.topic = json.getString("topic"); // this.partition = json.getInteger("partition"); // } // // /** // * Constructor (copy) // * // * @param that object to copy // */ // public TopicPartition(TopicPartition that) { // this.topic = that.topic; // this.partition = that.partition; // } // // /** // * @return the topic name // */ // public String getTopic() { // return this.topic; // } // // /** // * Set the topic name // * // * @param topic the topic name // * @return current instance of the class to be fluent // */ // public TopicPartition setTopic(String topic) { // this.topic = topic; // return this; // } // // /** // * @return the partition number // */ // public int getPartition() { // return this.partition; // } // // /** // * Set the partition number // * // * @param partition the partition number // * @return current instance of the class to be fluent // */ // public TopicPartition setPartition(int partition) { // this.partition = partition; // return this; // } // // /** // * Convert object to JSON representation // * // * @return JSON representation // */ // public JsonObject toJson() { // return new JsonObject().put("topic", this.topic).put("partition", this.partition); // } // // @Override // public String toString() { // // return "TopicPartition{" + // "topic=" + this.topic + // ", partition=" + this.partition + // "}"; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TopicPartition that = (TopicPartition) o; // // if (partition != that.partition) return false; // return topic != null ? topic.equals(that.topic) : that.topic == null; // } // // @Override // public int hashCode() { // int result = 1; // result = 31 * result + partition; // result = 31 * result + (topic != null ? topic.hashCode() : 0); // return result; // } // }
import io.vertx.codegen.annotations.DataObject; import io.vertx.core.json.JsonObject; import io.vertx.kafka.client.common.TopicPartition; import java.util.Set;
/* * Copyright 2019 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.admin; /** * A description of the assignments of a specific group member */ @DataObject(generateConverter = true) public class MemberAssignment {
// Path: src/main/java/io/vertx/kafka/client/common/TopicPartition.java // @DataObject // public class TopicPartition { // // private String topic; // private int partition; // // /** // * Constructor // */ // public TopicPartition() { // } // // /** // * Constructor // * // * @param topic the topic name // * @param partition the partition number // */ // public TopicPartition(String topic, int partition) { // this.topic = topic; // this.partition = partition; // } // // /** // * Constructor (from JSON representation) // * // * @param json JSON representation // */ // public TopicPartition(JsonObject json) { // this.topic = json.getString("topic"); // this.partition = json.getInteger("partition"); // } // // /** // * Constructor (copy) // * // * @param that object to copy // */ // public TopicPartition(TopicPartition that) { // this.topic = that.topic; // this.partition = that.partition; // } // // /** // * @return the topic name // */ // public String getTopic() { // return this.topic; // } // // /** // * Set the topic name // * // * @param topic the topic name // * @return current instance of the class to be fluent // */ // public TopicPartition setTopic(String topic) { // this.topic = topic; // return this; // } // // /** // * @return the partition number // */ // public int getPartition() { // return this.partition; // } // // /** // * Set the partition number // * // * @param partition the partition number // * @return current instance of the class to be fluent // */ // public TopicPartition setPartition(int partition) { // this.partition = partition; // return this; // } // // /** // * Convert object to JSON representation // * // * @return JSON representation // */ // public JsonObject toJson() { // return new JsonObject().put("topic", this.topic).put("partition", this.partition); // } // // @Override // public String toString() { // // return "TopicPartition{" + // "topic=" + this.topic + // ", partition=" + this.partition + // "}"; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TopicPartition that = (TopicPartition) o; // // if (partition != that.partition) return false; // return topic != null ? topic.equals(that.topic) : that.topic == null; // } // // @Override // public int hashCode() { // int result = 1; // result = 31 * result + partition; // result = 31 * result + (topic != null ? topic.hashCode() : 0); // return result; // } // } // Path: src/main/java/io/vertx/kafka/admin/MemberAssignment.java import io.vertx.codegen.annotations.DataObject; import io.vertx.core.json.JsonObject; import io.vertx.kafka.client.common.TopicPartition; import java.util.Set; /* * Copyright 2019 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.admin; /** * A description of the assignments of a specific group member */ @DataObject(generateConverter = true) public class MemberAssignment {
private Set<TopicPartition> topicPartitions;
vert-x3/vertx-kafka-client
src/main/java/io/vertx/kafka/client/consumer/impl/KafkaConsumerRecordImpl.java
// Path: src/main/java/io/vertx/kafka/client/consumer/KafkaConsumerRecord.java // @VertxGen // public interface KafkaConsumerRecord<K, V> { // // /** // * @return the topic this record is received from // */ // String topic(); // // /** // * @return the partition from which this record is received // */ // int partition(); // // /** // * @return the position of this record in the corresponding Kafka partition. // */ // long offset(); // // /** // * @return the timestamp of this record // */ // long timestamp(); // // /** // * @return the timestamp type of this record // */ // TimestampType timestampType(); // // /** // * @return the checksum (CRC32) of the record. // * // * @deprecated As of Kafka 0.11.0. Because of the potential for message format conversion on the broker, the // * checksum returned by the broker may not match what was computed by the producer. // * It is therefore unsafe to depend on this checksum for end-to-end delivery guarantees. Additionally, // * message format v2 does not include a record-level checksum (for performance, the record checksum // * was replaced with a batch checksum). To maintain compatibility, a partial checksum computed from // * the record timestamp, serialized key size, and serialized value size is returned instead, but // * this should not be depended on for end-to-end reliability. // */ // @Deprecated // long checksum(); // // /** // * @return the key (or null if no key is specified) // */ // K key(); // // /** // * @return the value // */ // V value(); // // /** // * @return the list of consumer record headers // */ // List<KafkaHeader> headers(); // // /** // * @return the native Kafka consumer record with backed information // */ // @GenIgnore // ConsumerRecord<K, V> record(); // } // // Path: src/main/java/io/vertx/kafka/client/producer/KafkaHeader.java // @VertxGen // public interface KafkaHeader { // // static KafkaHeader header(String key, Buffer value) { // return new KafkaHeaderImpl(key, value); // } // // static KafkaHeader header(String key, String value) { // return new KafkaHeaderImpl(key, value); // } // // @GenIgnore // static KafkaHeader header(String key, byte[] value) { // return new KafkaHeaderImpl(key, Buffer.buffer(value)); // } // // /** // * @return the buffer key // */ // @CacheReturn // String key(); // // /** // * @return the buffer value // */ // @CacheReturn // Buffer value(); // // }
import io.vertx.kafka.client.consumer.KafkaConsumerRecord; import io.vertx.kafka.client.producer.KafkaHeader; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.header.Header; import org.apache.kafka.common.record.TimestampType; import java.util.ArrayList; import java.util.Collections; import java.util.List;
/* * Copyright 2016 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.consumer.impl; /** * Vert.x Kafka consumer record implementation */ public class KafkaConsumerRecordImpl<K, V> implements KafkaConsumerRecord<K, V> { private final ConsumerRecord<K, V> record;
// Path: src/main/java/io/vertx/kafka/client/consumer/KafkaConsumerRecord.java // @VertxGen // public interface KafkaConsumerRecord<K, V> { // // /** // * @return the topic this record is received from // */ // String topic(); // // /** // * @return the partition from which this record is received // */ // int partition(); // // /** // * @return the position of this record in the corresponding Kafka partition. // */ // long offset(); // // /** // * @return the timestamp of this record // */ // long timestamp(); // // /** // * @return the timestamp type of this record // */ // TimestampType timestampType(); // // /** // * @return the checksum (CRC32) of the record. // * // * @deprecated As of Kafka 0.11.0. Because of the potential for message format conversion on the broker, the // * checksum returned by the broker may not match what was computed by the producer. // * It is therefore unsafe to depend on this checksum for end-to-end delivery guarantees. Additionally, // * message format v2 does not include a record-level checksum (for performance, the record checksum // * was replaced with a batch checksum). To maintain compatibility, a partial checksum computed from // * the record timestamp, serialized key size, and serialized value size is returned instead, but // * this should not be depended on for end-to-end reliability. // */ // @Deprecated // long checksum(); // // /** // * @return the key (or null if no key is specified) // */ // K key(); // // /** // * @return the value // */ // V value(); // // /** // * @return the list of consumer record headers // */ // List<KafkaHeader> headers(); // // /** // * @return the native Kafka consumer record with backed information // */ // @GenIgnore // ConsumerRecord<K, V> record(); // } // // Path: src/main/java/io/vertx/kafka/client/producer/KafkaHeader.java // @VertxGen // public interface KafkaHeader { // // static KafkaHeader header(String key, Buffer value) { // return new KafkaHeaderImpl(key, value); // } // // static KafkaHeader header(String key, String value) { // return new KafkaHeaderImpl(key, value); // } // // @GenIgnore // static KafkaHeader header(String key, byte[] value) { // return new KafkaHeaderImpl(key, Buffer.buffer(value)); // } // // /** // * @return the buffer key // */ // @CacheReturn // String key(); // // /** // * @return the buffer value // */ // @CacheReturn // Buffer value(); // // } // Path: src/main/java/io/vertx/kafka/client/consumer/impl/KafkaConsumerRecordImpl.java import io.vertx.kafka.client.consumer.KafkaConsumerRecord; import io.vertx.kafka.client.producer.KafkaHeader; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.header.Header; import org.apache.kafka.common.record.TimestampType; import java.util.ArrayList; import java.util.Collections; import java.util.List; /* * Copyright 2016 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.consumer.impl; /** * Vert.x Kafka consumer record implementation */ public class KafkaConsumerRecordImpl<K, V> implements KafkaConsumerRecord<K, V> { private final ConsumerRecord<K, V> record;
private List<KafkaHeader> headers;
vert-x3/vertx-kafka-client
src/main/java/io/vertx/kafka/client/consumer/impl/KafkaConsumerRecordsImpl.java
// Path: src/main/java/io/vertx/kafka/client/consumer/KafkaConsumerRecord.java // @VertxGen // public interface KafkaConsumerRecord<K, V> { // // /** // * @return the topic this record is received from // */ // String topic(); // // /** // * @return the partition from which this record is received // */ // int partition(); // // /** // * @return the position of this record in the corresponding Kafka partition. // */ // long offset(); // // /** // * @return the timestamp of this record // */ // long timestamp(); // // /** // * @return the timestamp type of this record // */ // TimestampType timestampType(); // // /** // * @return the checksum (CRC32) of the record. // * // * @deprecated As of Kafka 0.11.0. Because of the potential for message format conversion on the broker, the // * checksum returned by the broker may not match what was computed by the producer. // * It is therefore unsafe to depend on this checksum for end-to-end delivery guarantees. Additionally, // * message format v2 does not include a record-level checksum (for performance, the record checksum // * was replaced with a batch checksum). To maintain compatibility, a partial checksum computed from // * the record timestamp, serialized key size, and serialized value size is returned instead, but // * this should not be depended on for end-to-end reliability. // */ // @Deprecated // long checksum(); // // /** // * @return the key (or null if no key is specified) // */ // K key(); // // /** // * @return the value // */ // V value(); // // /** // * @return the list of consumer record headers // */ // List<KafkaHeader> headers(); // // /** // * @return the native Kafka consumer record with backed information // */ // @GenIgnore // ConsumerRecord<K, V> record(); // } // // Path: src/main/java/io/vertx/kafka/client/consumer/KafkaConsumerRecords.java // @VertxGen // public interface KafkaConsumerRecords<K, V> { // /** // * @return the total number of records in this batch // */ // int size(); // /** // * @return whether this batch contains any records // */ // boolean isEmpty(); // /** // * Get the record at the given index // * @param index the index of the record to get // * @throws IndexOutOfBoundsException if index <0 or index>={@link #size()} // */ // KafkaConsumerRecord<K, V> recordAt(int index); // // /** // * @return the native Kafka consumer records with backed information // */ // @GenIgnore // ConsumerRecords<K, V> records(); // // }
import java.util.ArrayList; import java.util.List; import org.apache.kafka.clients.consumer.ConsumerRecords; import io.vertx.kafka.client.consumer.KafkaConsumerRecord; import io.vertx.kafka.client.consumer.KafkaConsumerRecords;
/* * Copyright 2016 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.consumer.impl; public class KafkaConsumerRecordsImpl<K, V> implements KafkaConsumerRecords<K, V>{ private final ConsumerRecords<K, V> records;
// Path: src/main/java/io/vertx/kafka/client/consumer/KafkaConsumerRecord.java // @VertxGen // public interface KafkaConsumerRecord<K, V> { // // /** // * @return the topic this record is received from // */ // String topic(); // // /** // * @return the partition from which this record is received // */ // int partition(); // // /** // * @return the position of this record in the corresponding Kafka partition. // */ // long offset(); // // /** // * @return the timestamp of this record // */ // long timestamp(); // // /** // * @return the timestamp type of this record // */ // TimestampType timestampType(); // // /** // * @return the checksum (CRC32) of the record. // * // * @deprecated As of Kafka 0.11.0. Because of the potential for message format conversion on the broker, the // * checksum returned by the broker may not match what was computed by the producer. // * It is therefore unsafe to depend on this checksum for end-to-end delivery guarantees. Additionally, // * message format v2 does not include a record-level checksum (for performance, the record checksum // * was replaced with a batch checksum). To maintain compatibility, a partial checksum computed from // * the record timestamp, serialized key size, and serialized value size is returned instead, but // * this should not be depended on for end-to-end reliability. // */ // @Deprecated // long checksum(); // // /** // * @return the key (or null if no key is specified) // */ // K key(); // // /** // * @return the value // */ // V value(); // // /** // * @return the list of consumer record headers // */ // List<KafkaHeader> headers(); // // /** // * @return the native Kafka consumer record with backed information // */ // @GenIgnore // ConsumerRecord<K, V> record(); // } // // Path: src/main/java/io/vertx/kafka/client/consumer/KafkaConsumerRecords.java // @VertxGen // public interface KafkaConsumerRecords<K, V> { // /** // * @return the total number of records in this batch // */ // int size(); // /** // * @return whether this batch contains any records // */ // boolean isEmpty(); // /** // * Get the record at the given index // * @param index the index of the record to get // * @throws IndexOutOfBoundsException if index <0 or index>={@link #size()} // */ // KafkaConsumerRecord<K, V> recordAt(int index); // // /** // * @return the native Kafka consumer records with backed information // */ // @GenIgnore // ConsumerRecords<K, V> records(); // // } // Path: src/main/java/io/vertx/kafka/client/consumer/impl/KafkaConsumerRecordsImpl.java import java.util.ArrayList; import java.util.List; import org.apache.kafka.clients.consumer.ConsumerRecords; import io.vertx.kafka.client.consumer.KafkaConsumerRecord; import io.vertx.kafka.client.consumer.KafkaConsumerRecords; /* * Copyright 2016 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.consumer.impl; public class KafkaConsumerRecordsImpl<K, V> implements KafkaConsumerRecords<K, V>{ private final ConsumerRecords<K, V> records;
private List<KafkaConsumerRecord<K, V>> list;
vert-x3/vertx-kafka-client
src/main/java/io/vertx/kafka/admin/ListConsumerGroupOffsetsOptions.java
// Path: src/main/java/io/vertx/kafka/client/common/TopicPartition.java // @DataObject // public class TopicPartition { // // private String topic; // private int partition; // // /** // * Constructor // */ // public TopicPartition() { // } // // /** // * Constructor // * // * @param topic the topic name // * @param partition the partition number // */ // public TopicPartition(String topic, int partition) { // this.topic = topic; // this.partition = partition; // } // // /** // * Constructor (from JSON representation) // * // * @param json JSON representation // */ // public TopicPartition(JsonObject json) { // this.topic = json.getString("topic"); // this.partition = json.getInteger("partition"); // } // // /** // * Constructor (copy) // * // * @param that object to copy // */ // public TopicPartition(TopicPartition that) { // this.topic = that.topic; // this.partition = that.partition; // } // // /** // * @return the topic name // */ // public String getTopic() { // return this.topic; // } // // /** // * Set the topic name // * // * @param topic the topic name // * @return current instance of the class to be fluent // */ // public TopicPartition setTopic(String topic) { // this.topic = topic; // return this; // } // // /** // * @return the partition number // */ // public int getPartition() { // return this.partition; // } // // /** // * Set the partition number // * // * @param partition the partition number // * @return current instance of the class to be fluent // */ // public TopicPartition setPartition(int partition) { // this.partition = partition; // return this; // } // // /** // * Convert object to JSON representation // * // * @return JSON representation // */ // public JsonObject toJson() { // return new JsonObject().put("topic", this.topic).put("partition", this.partition); // } // // @Override // public String toString() { // // return "TopicPartition{" + // "topic=" + this.topic + // ", partition=" + this.partition + // "}"; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TopicPartition that = (TopicPartition) o; // // if (partition != that.partition) return false; // return topic != null ? topic.equals(that.topic) : that.topic == null; // } // // @Override // public int hashCode() { // int result = 1; // result = 31 * result + partition; // result = 31 * result + (topic != null ? topic.hashCode() : 0); // return result; // } // }
import io.vertx.codegen.annotations.DataObject; import io.vertx.core.json.JsonObject; import io.vertx.kafka.client.common.TopicPartition; import java.util.List;
package io.vertx.kafka.admin; @DataObject(generateConverter = true) public class ListConsumerGroupOffsetsOptions {
// Path: src/main/java/io/vertx/kafka/client/common/TopicPartition.java // @DataObject // public class TopicPartition { // // private String topic; // private int partition; // // /** // * Constructor // */ // public TopicPartition() { // } // // /** // * Constructor // * // * @param topic the topic name // * @param partition the partition number // */ // public TopicPartition(String topic, int partition) { // this.topic = topic; // this.partition = partition; // } // // /** // * Constructor (from JSON representation) // * // * @param json JSON representation // */ // public TopicPartition(JsonObject json) { // this.topic = json.getString("topic"); // this.partition = json.getInteger("partition"); // } // // /** // * Constructor (copy) // * // * @param that object to copy // */ // public TopicPartition(TopicPartition that) { // this.topic = that.topic; // this.partition = that.partition; // } // // /** // * @return the topic name // */ // public String getTopic() { // return this.topic; // } // // /** // * Set the topic name // * // * @param topic the topic name // * @return current instance of the class to be fluent // */ // public TopicPartition setTopic(String topic) { // this.topic = topic; // return this; // } // // /** // * @return the partition number // */ // public int getPartition() { // return this.partition; // } // // /** // * Set the partition number // * // * @param partition the partition number // * @return current instance of the class to be fluent // */ // public TopicPartition setPartition(int partition) { // this.partition = partition; // return this; // } // // /** // * Convert object to JSON representation // * // * @return JSON representation // */ // public JsonObject toJson() { // return new JsonObject().put("topic", this.topic).put("partition", this.partition); // } // // @Override // public String toString() { // // return "TopicPartition{" + // "topic=" + this.topic + // ", partition=" + this.partition + // "}"; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TopicPartition that = (TopicPartition) o; // // if (partition != that.partition) return false; // return topic != null ? topic.equals(that.topic) : that.topic == null; // } // // @Override // public int hashCode() { // int result = 1; // result = 31 * result + partition; // result = 31 * result + (topic != null ? topic.hashCode() : 0); // return result; // } // } // Path: src/main/java/io/vertx/kafka/admin/ListConsumerGroupOffsetsOptions.java import io.vertx.codegen.annotations.DataObject; import io.vertx.core.json.JsonObject; import io.vertx.kafka.client.common.TopicPartition; import java.util.List; package io.vertx.kafka.admin; @DataObject(generateConverter = true) public class ListConsumerGroupOffsetsOptions {
private List<TopicPartition> topicPartitions = null;
vert-x3/vertx-kafka-client
src/test/java/io/vertx/kafka/client/tests/TopicPartitionTest.java
// Path: src/main/java/io/vertx/kafka/client/common/TopicPartition.java // @DataObject // public class TopicPartition { // // private String topic; // private int partition; // // /** // * Constructor // */ // public TopicPartition() { // } // // /** // * Constructor // * // * @param topic the topic name // * @param partition the partition number // */ // public TopicPartition(String topic, int partition) { // this.topic = topic; // this.partition = partition; // } // // /** // * Constructor (from JSON representation) // * // * @param json JSON representation // */ // public TopicPartition(JsonObject json) { // this.topic = json.getString("topic"); // this.partition = json.getInteger("partition"); // } // // /** // * Constructor (copy) // * // * @param that object to copy // */ // public TopicPartition(TopicPartition that) { // this.topic = that.topic; // this.partition = that.partition; // } // // /** // * @return the topic name // */ // public String getTopic() { // return this.topic; // } // // /** // * Set the topic name // * // * @param topic the topic name // * @return current instance of the class to be fluent // */ // public TopicPartition setTopic(String topic) { // this.topic = topic; // return this; // } // // /** // * @return the partition number // */ // public int getPartition() { // return this.partition; // } // // /** // * Set the partition number // * // * @param partition the partition number // * @return current instance of the class to be fluent // */ // public TopicPartition setPartition(int partition) { // this.partition = partition; // return this; // } // // /** // * Convert object to JSON representation // * // * @return JSON representation // */ // public JsonObject toJson() { // return new JsonObject().put("topic", this.topic).put("partition", this.partition); // } // // @Override // public String toString() { // // return "TopicPartition{" + // "topic=" + this.topic + // ", partition=" + this.partition + // "}"; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TopicPartition that = (TopicPartition) o; // // if (partition != that.partition) return false; // return topic != null ? topic.equals(that.topic) : that.topic == null; // } // // @Override // public int hashCode() { // int result = 1; // result = 31 * result + partition; // result = 31 * result + (topic != null ? topic.hashCode() : 0); // return result; // } // }
import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import io.vertx.kafka.client.common.TopicPartition; import org.junit.Test; import org.junit.runner.RunWith;
/* * Copyright 2018 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.tests; @RunWith(VertxUnitRunner.class) public class TopicPartitionTest { @Test public void testEquality(final TestContext context) {
// Path: src/main/java/io/vertx/kafka/client/common/TopicPartition.java // @DataObject // public class TopicPartition { // // private String topic; // private int partition; // // /** // * Constructor // */ // public TopicPartition() { // } // // /** // * Constructor // * // * @param topic the topic name // * @param partition the partition number // */ // public TopicPartition(String topic, int partition) { // this.topic = topic; // this.partition = partition; // } // // /** // * Constructor (from JSON representation) // * // * @param json JSON representation // */ // public TopicPartition(JsonObject json) { // this.topic = json.getString("topic"); // this.partition = json.getInteger("partition"); // } // // /** // * Constructor (copy) // * // * @param that object to copy // */ // public TopicPartition(TopicPartition that) { // this.topic = that.topic; // this.partition = that.partition; // } // // /** // * @return the topic name // */ // public String getTopic() { // return this.topic; // } // // /** // * Set the topic name // * // * @param topic the topic name // * @return current instance of the class to be fluent // */ // public TopicPartition setTopic(String topic) { // this.topic = topic; // return this; // } // // /** // * @return the partition number // */ // public int getPartition() { // return this.partition; // } // // /** // * Set the partition number // * // * @param partition the partition number // * @return current instance of the class to be fluent // */ // public TopicPartition setPartition(int partition) { // this.partition = partition; // return this; // } // // /** // * Convert object to JSON representation // * // * @return JSON representation // */ // public JsonObject toJson() { // return new JsonObject().put("topic", this.topic).put("partition", this.partition); // } // // @Override // public String toString() { // // return "TopicPartition{" + // "topic=" + this.topic + // ", partition=" + this.partition + // "}"; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TopicPartition that = (TopicPartition) o; // // if (partition != that.partition) return false; // return topic != null ? topic.equals(that.topic) : that.topic == null; // } // // @Override // public int hashCode() { // int result = 1; // result = 31 * result + partition; // result = 31 * result + (topic != null ? topic.hashCode() : 0); // return result; // } // } // Path: src/test/java/io/vertx/kafka/client/tests/TopicPartitionTest.java import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import io.vertx.kafka.client.common.TopicPartition; import org.junit.Test; import org.junit.runner.RunWith; /* * Copyright 2018 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.tests; @RunWith(VertxUnitRunner.class) public class TopicPartitionTest { @Test public void testEquality(final TestContext context) {
final TopicPartition t1 = new TopicPartition("topic1", 0);
vert-x3/vertx-kafka-client
src/main/java/io/vertx/kafka/client/producer/KafkaProducerRecord.java
// Path: src/main/java/io/vertx/kafka/client/producer/impl/KafkaProducerRecordImpl.java // public class KafkaProducerRecordImpl<K, V> implements KafkaProducerRecord<K, V> { // // private final String topic; // private final K key; // private final V value; // private final Long timestamp; // private final Integer partition; // private final List<KafkaHeader> headers = new ArrayList<>(); // // /** // * Constructor // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param timestamp the timestamp of this record // * @param partition the partition to which the record will be sent (or null if no partition was specified) // */ // public KafkaProducerRecordImpl(String topic, K key, V value, Long timestamp, Integer partition) { // // this.topic = topic; // this.key = key; // this.value = value; // this.timestamp = timestamp; // this.partition = partition; // } // // /** // * Constructor // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param partition the partition to which the record will be sent (or null if no partition was specified) // */ // public KafkaProducerRecordImpl(String topic, K key, V value, Integer partition) { // // this.topic = topic; // this.key = key; // this.value = value; // this.timestamp = null; // this.partition = partition; // } // // /** // * Constructor // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // */ // public KafkaProducerRecordImpl(String topic, K key, V value) { // // this.topic = topic; // this.key = key; // this.value = value; // this.timestamp = null; // this.partition = null; // } // // /** // * Constructor // * // * @param topic the topic this record is being sent to // * @param value the value // */ // public KafkaProducerRecordImpl(String topic, V value) { // // this.topic = topic; // this.key = null; // this.value = value; // this.timestamp = null; // this.partition = null; // } // // @Override // public String topic() { // return topic; // } // // @Override // public K key() { // return key; // } // // @Override // public Long timestamp() { // return timestamp; // } // // @Override // public V value() { // return value; // } // // @Override // public Integer partition() { // return partition; // } // // @Override // public KafkaProducerRecord<K, V> addHeader(String key, Buffer value) { // return addHeader(new KafkaHeaderImpl(key, value)); // } // // @Override // public KafkaProducerRecord<K, V> addHeader(String key, String value) { // return addHeader(new KafkaHeaderImpl(key, value)); // } // // @Override // public KafkaProducerRecord<K, V> addHeader(KafkaHeader header) { // headers.add(header); // return this; // } // // @Override // public KafkaProducerRecord<K, V> addHeaders(List<KafkaHeader> headers) { // this.headers.addAll(headers); // return this; // } // // @Override // public ProducerRecord<K, V> record() { // if (headers.isEmpty()) { // return new ProducerRecord<>(topic, partition, timestamp, key, value); // } else { // return new ProducerRecord<>( // topic, // partition, // timestamp, // key, // value, // headers.stream() // .map(header -> new RecordHeader(header.key(), header.value().getBytes())) // .collect(Collectors.toList())); // } // } // // @Override // public List<KafkaHeader> headers() { // return headers; // } // // @Override // public String toString() { // // return "KafkaProducerRecord{" + // "topic=" + this.topic + // ",partition=" + this.partition + // ",timestamp=" + this.timestamp + // ",key=" + this.key + // ",value=" + this.value + // ",headers=" + this.headers + // "}"; // } // }
import io.vertx.codegen.annotations.CacheReturn; import io.vertx.codegen.annotations.Fluent; import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.VertxGen; import io.vertx.core.buffer.Buffer; import io.vertx.kafka.client.producer.impl.KafkaProducerRecordImpl; import org.apache.kafka.clients.producer.ProducerRecord; import java.util.List;
/* * Copyright 2016 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.producer; /** * Vert.x Kafka producer record. */ @VertxGen public interface KafkaProducerRecord<K, V> { /** * Create a concrete instance of a Vert.x producer record * * @param topic the topic this record is being sent to * @param key the key (or null if no key is specified) * @param value the value * @param timestamp the timestamp of this record * @param partition the partition to which the record will be sent (or null if no partition was specified) * @param <K> key type * @param <V> value type * @return Vert.x producer record */ static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Long timestamp, Integer partition) {
// Path: src/main/java/io/vertx/kafka/client/producer/impl/KafkaProducerRecordImpl.java // public class KafkaProducerRecordImpl<K, V> implements KafkaProducerRecord<K, V> { // // private final String topic; // private final K key; // private final V value; // private final Long timestamp; // private final Integer partition; // private final List<KafkaHeader> headers = new ArrayList<>(); // // /** // * Constructor // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param timestamp the timestamp of this record // * @param partition the partition to which the record will be sent (or null if no partition was specified) // */ // public KafkaProducerRecordImpl(String topic, K key, V value, Long timestamp, Integer partition) { // // this.topic = topic; // this.key = key; // this.value = value; // this.timestamp = timestamp; // this.partition = partition; // } // // /** // * Constructor // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // * @param partition the partition to which the record will be sent (or null if no partition was specified) // */ // public KafkaProducerRecordImpl(String topic, K key, V value, Integer partition) { // // this.topic = topic; // this.key = key; // this.value = value; // this.timestamp = null; // this.partition = partition; // } // // /** // * Constructor // * // * @param topic the topic this record is being sent to // * @param key the key (or null if no key is specified) // * @param value the value // */ // public KafkaProducerRecordImpl(String topic, K key, V value) { // // this.topic = topic; // this.key = key; // this.value = value; // this.timestamp = null; // this.partition = null; // } // // /** // * Constructor // * // * @param topic the topic this record is being sent to // * @param value the value // */ // public KafkaProducerRecordImpl(String topic, V value) { // // this.topic = topic; // this.key = null; // this.value = value; // this.timestamp = null; // this.partition = null; // } // // @Override // public String topic() { // return topic; // } // // @Override // public K key() { // return key; // } // // @Override // public Long timestamp() { // return timestamp; // } // // @Override // public V value() { // return value; // } // // @Override // public Integer partition() { // return partition; // } // // @Override // public KafkaProducerRecord<K, V> addHeader(String key, Buffer value) { // return addHeader(new KafkaHeaderImpl(key, value)); // } // // @Override // public KafkaProducerRecord<K, V> addHeader(String key, String value) { // return addHeader(new KafkaHeaderImpl(key, value)); // } // // @Override // public KafkaProducerRecord<K, V> addHeader(KafkaHeader header) { // headers.add(header); // return this; // } // // @Override // public KafkaProducerRecord<K, V> addHeaders(List<KafkaHeader> headers) { // this.headers.addAll(headers); // return this; // } // // @Override // public ProducerRecord<K, V> record() { // if (headers.isEmpty()) { // return new ProducerRecord<>(topic, partition, timestamp, key, value); // } else { // return new ProducerRecord<>( // topic, // partition, // timestamp, // key, // value, // headers.stream() // .map(header -> new RecordHeader(header.key(), header.value().getBytes())) // .collect(Collectors.toList())); // } // } // // @Override // public List<KafkaHeader> headers() { // return headers; // } // // @Override // public String toString() { // // return "KafkaProducerRecord{" + // "topic=" + this.topic + // ",partition=" + this.partition + // ",timestamp=" + this.timestamp + // ",key=" + this.key + // ",value=" + this.value + // ",headers=" + this.headers + // "}"; // } // } // Path: src/main/java/io/vertx/kafka/client/producer/KafkaProducerRecord.java import io.vertx.codegen.annotations.CacheReturn; import io.vertx.codegen.annotations.Fluent; import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.VertxGen; import io.vertx.core.buffer.Buffer; import io.vertx.kafka.client.producer.impl.KafkaProducerRecordImpl; import org.apache.kafka.clients.producer.ProducerRecord; import java.util.List; /* * Copyright 2016 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.producer; /** * Vert.x Kafka producer record. */ @VertxGen public interface KafkaProducerRecord<K, V> { /** * Create a concrete instance of a Vert.x producer record * * @param topic the topic this record is being sent to * @param key the key (or null if no key is specified) * @param value the value * @param timestamp the timestamp of this record * @param partition the partition to which the record will be sent (or null if no partition was specified) * @param <K> key type * @param <V> value type * @return Vert.x producer record */ static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Long timestamp, Integer partition) {
return new KafkaProducerRecordImpl<>(topic, key, value, timestamp, partition);
vert-x3/vertx-kafka-client
src/main/java/io/vertx/kafka/client/common/tracing/ProducerTracer.java
// Path: src/main/java/io/vertx/kafka/client/common/KafkaClientOptions.java // @DataObject(generateConverter = true) // public class KafkaClientOptions { // /** // * Default peer address to set in traces tags is null, and will automatically pick up bootstrap server from config // */ // public static final String DEFAULT_TRACE_PEER_ADDRESS = null; // // /** // * Default tracing policy is 'propagate' // */ // public static final TracingPolicy DEFAULT_TRACING_POLICY = TracingPolicy.PROPAGATE; // // private Map<String, Object> config; // private String tracePeerAddress = DEFAULT_TRACE_PEER_ADDRESS; // private TracingPolicy tracingPolicy = DEFAULT_TRACING_POLICY; // // public KafkaClientOptions() { // } // // public KafkaClientOptions(JsonObject json) { // this(); // KafkaClientOptionsConverter.fromJson(json, this); // } // // /** // * Create KafkaClientOptions from underlying Kafka config as map // * @param config config map to be passed down to underlying Kafka client // * @return an instance of KafkaClientOptions // */ // public static KafkaClientOptions fromMap(Map<String, Object> config, boolean isProducer) { // String tracePeerAddress = (String) config.getOrDefault(isProducer ? ProducerConfig.BOOTSTRAP_SERVERS_CONFIG : ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, ""); // return new KafkaClientOptions().setTracePeerAddress(tracePeerAddress); // } // // /** // * Create KafkaClientOptions from underlying Kafka config as Properties // * @param config config properties to be passed down to underlying Kafka client // * @return an instance of KafkaClientOptions // */ // public static KafkaClientOptions fromProperties(Properties config, boolean isProducer) { // String tracePeerAddress = (String) config.getOrDefault(isProducer ? ProducerConfig.BOOTSTRAP_SERVERS_CONFIG : ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, ""); // return new KafkaClientOptions().setTracePeerAddress(tracePeerAddress); // } // // /** // * @return the kafka config // */ // public Map<String, Object> getConfig() { // return config; // } // // /** // * Set the Kafka config. // * // * @param config the config // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setConfig(Map<String, Object> config) { // this.config = config; // return this; // } // // /** // * Set a Kafka config entry. // * // * @param key the config key // * @param value the config value // * @return a reference to this, so the API can be used fluently // */ // @GenIgnore // public KafkaClientOptions setConfig(String key, Object value) { // if (config == null) { // config = new HashMap<>(); // } // config.put(key, value); // return this; // } // // /** // * @return the kafka tracing policy // */ // public TracingPolicy getTracingPolicy() { // return tracingPolicy; // } // // /** // * Set the Kafka tracing policy. // * // * @param tracingPolicy the tracing policy // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setTracingPolicy(TracingPolicy tracingPolicy) { // this.tracingPolicy = tracingPolicy; // return this; // } // // /** // * @return the Kafka "peer address" to show in trace tags // */ // public String getTracePeerAddress() { // return tracePeerAddress; // } // // /** // * Set the Kafka address to show in trace tags. // * Or leave it unset to automatically pick up bootstrap server from config instead. // * // * @param tracePeerAddress the Kafka "peer address" to show in trace tags // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setTracePeerAddress(String tracePeerAddress) { // this.tracePeerAddress = tracePeerAddress; // return this; // } // // public JsonObject toJson() { // return new JsonObject(); // } // }
import io.vertx.core.Context; import io.vertx.core.spi.tracing.SpanKind; import io.vertx.core.spi.tracing.TagExtractor; import io.vertx.core.spi.tracing.VertxTracer; import io.vertx.core.tracing.TracingPolicy; import io.vertx.kafka.client.common.KafkaClientOptions; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.utils.Utils;
/* * Copyright 2020 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.common.tracing; /** * Tracer for Kafka producer, wrapping the generic tracer. */ public class ProducerTracer<S> { private final VertxTracer<Void, S> tracer; private final String address; private final String hostname; private final String port; private final TracingPolicy policy; /** * Creates a ProducerTracer, which provides an opinionated facade for using {@link io.vertx.core.spi.tracing.VertxTracer} * with a Kafka Producer use case. * The method will return {@code null} if Tracing is not setup in Vert.x, or if {@code TracingPolicy.IGNORE} is used. * @param tracer the generic tracer object * @param opts Kafka client options * @param <S> the type of spans that is going to be generated, depending on the tracing system (zipkin, opentracing ...) * @return a new instance of {@code ProducerTracer}, or {@code null} */
// Path: src/main/java/io/vertx/kafka/client/common/KafkaClientOptions.java // @DataObject(generateConverter = true) // public class KafkaClientOptions { // /** // * Default peer address to set in traces tags is null, and will automatically pick up bootstrap server from config // */ // public static final String DEFAULT_TRACE_PEER_ADDRESS = null; // // /** // * Default tracing policy is 'propagate' // */ // public static final TracingPolicy DEFAULT_TRACING_POLICY = TracingPolicy.PROPAGATE; // // private Map<String, Object> config; // private String tracePeerAddress = DEFAULT_TRACE_PEER_ADDRESS; // private TracingPolicy tracingPolicy = DEFAULT_TRACING_POLICY; // // public KafkaClientOptions() { // } // // public KafkaClientOptions(JsonObject json) { // this(); // KafkaClientOptionsConverter.fromJson(json, this); // } // // /** // * Create KafkaClientOptions from underlying Kafka config as map // * @param config config map to be passed down to underlying Kafka client // * @return an instance of KafkaClientOptions // */ // public static KafkaClientOptions fromMap(Map<String, Object> config, boolean isProducer) { // String tracePeerAddress = (String) config.getOrDefault(isProducer ? ProducerConfig.BOOTSTRAP_SERVERS_CONFIG : ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, ""); // return new KafkaClientOptions().setTracePeerAddress(tracePeerAddress); // } // // /** // * Create KafkaClientOptions from underlying Kafka config as Properties // * @param config config properties to be passed down to underlying Kafka client // * @return an instance of KafkaClientOptions // */ // public static KafkaClientOptions fromProperties(Properties config, boolean isProducer) { // String tracePeerAddress = (String) config.getOrDefault(isProducer ? ProducerConfig.BOOTSTRAP_SERVERS_CONFIG : ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, ""); // return new KafkaClientOptions().setTracePeerAddress(tracePeerAddress); // } // // /** // * @return the kafka config // */ // public Map<String, Object> getConfig() { // return config; // } // // /** // * Set the Kafka config. // * // * @param config the config // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setConfig(Map<String, Object> config) { // this.config = config; // return this; // } // // /** // * Set a Kafka config entry. // * // * @param key the config key // * @param value the config value // * @return a reference to this, so the API can be used fluently // */ // @GenIgnore // public KafkaClientOptions setConfig(String key, Object value) { // if (config == null) { // config = new HashMap<>(); // } // config.put(key, value); // return this; // } // // /** // * @return the kafka tracing policy // */ // public TracingPolicy getTracingPolicy() { // return tracingPolicy; // } // // /** // * Set the Kafka tracing policy. // * // * @param tracingPolicy the tracing policy // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setTracingPolicy(TracingPolicy tracingPolicy) { // this.tracingPolicy = tracingPolicy; // return this; // } // // /** // * @return the Kafka "peer address" to show in trace tags // */ // public String getTracePeerAddress() { // return tracePeerAddress; // } // // /** // * Set the Kafka address to show in trace tags. // * Or leave it unset to automatically pick up bootstrap server from config instead. // * // * @param tracePeerAddress the Kafka "peer address" to show in trace tags // * @return a reference to this, so the API can be used fluently // */ // public KafkaClientOptions setTracePeerAddress(String tracePeerAddress) { // this.tracePeerAddress = tracePeerAddress; // return this; // } // // public JsonObject toJson() { // return new JsonObject(); // } // } // Path: src/main/java/io/vertx/kafka/client/common/tracing/ProducerTracer.java import io.vertx.core.Context; import io.vertx.core.spi.tracing.SpanKind; import io.vertx.core.spi.tracing.TagExtractor; import io.vertx.core.spi.tracing.VertxTracer; import io.vertx.core.tracing.TracingPolicy; import io.vertx.kafka.client.common.KafkaClientOptions; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.utils.Utils; /* * Copyright 2020 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.common.tracing; /** * Tracer for Kafka producer, wrapping the generic tracer. */ public class ProducerTracer<S> { private final VertxTracer<Void, S> tracer; private final String address; private final String hostname; private final String port; private final TracingPolicy policy; /** * Creates a ProducerTracer, which provides an opinionated facade for using {@link io.vertx.core.spi.tracing.VertxTracer} * with a Kafka Producer use case. * The method will return {@code null} if Tracing is not setup in Vert.x, or if {@code TracingPolicy.IGNORE} is used. * @param tracer the generic tracer object * @param opts Kafka client options * @param <S> the type of spans that is going to be generated, depending on the tracing system (zipkin, opentracing ...) * @return a new instance of {@code ProducerTracer}, or {@code null} */
public static <S> ProducerTracer create(VertxTracer tracer, KafkaClientOptions opts) {
vert-x3/vertx-kafka-client
src/main/java/io/vertx/kafka/client/consumer/KafkaConsumerRecord.java
// Path: src/main/java/io/vertx/kafka/client/producer/KafkaHeader.java // @VertxGen // public interface KafkaHeader { // // static KafkaHeader header(String key, Buffer value) { // return new KafkaHeaderImpl(key, value); // } // // static KafkaHeader header(String key, String value) { // return new KafkaHeaderImpl(key, value); // } // // @GenIgnore // static KafkaHeader header(String key, byte[] value) { // return new KafkaHeaderImpl(key, Buffer.buffer(value)); // } // // /** // * @return the buffer key // */ // @CacheReturn // String key(); // // /** // * @return the buffer value // */ // @CacheReturn // Buffer value(); // // }
import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.VertxGen; import io.vertx.kafka.client.producer.KafkaHeader; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.record.TimestampType; import java.util.List;
/* * Copyright 2016 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.consumer; /** * Vert.x Kafka consumer record */ @VertxGen public interface KafkaConsumerRecord<K, V> { /** * @return the topic this record is received from */ String topic(); /** * @return the partition from which this record is received */ int partition(); /** * @return the position of this record in the corresponding Kafka partition. */ long offset(); /** * @return the timestamp of this record */ long timestamp(); /** * @return the timestamp type of this record */ TimestampType timestampType(); /** * @return the checksum (CRC32) of the record. * * @deprecated As of Kafka 0.11.0. Because of the potential for message format conversion on the broker, the * checksum returned by the broker may not match what was computed by the producer. * It is therefore unsafe to depend on this checksum for end-to-end delivery guarantees. Additionally, * message format v2 does not include a record-level checksum (for performance, the record checksum * was replaced with a batch checksum). To maintain compatibility, a partial checksum computed from * the record timestamp, serialized key size, and serialized value size is returned instead, but * this should not be depended on for end-to-end reliability. */ @Deprecated long checksum(); /** * @return the key (or null if no key is specified) */ K key(); /** * @return the value */ V value(); /** * @return the list of consumer record headers */
// Path: src/main/java/io/vertx/kafka/client/producer/KafkaHeader.java // @VertxGen // public interface KafkaHeader { // // static KafkaHeader header(String key, Buffer value) { // return new KafkaHeaderImpl(key, value); // } // // static KafkaHeader header(String key, String value) { // return new KafkaHeaderImpl(key, value); // } // // @GenIgnore // static KafkaHeader header(String key, byte[] value) { // return new KafkaHeaderImpl(key, Buffer.buffer(value)); // } // // /** // * @return the buffer key // */ // @CacheReturn // String key(); // // /** // * @return the buffer value // */ // @CacheReturn // Buffer value(); // // } // Path: src/main/java/io/vertx/kafka/client/consumer/KafkaConsumerRecord.java import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.VertxGen; import io.vertx.kafka.client.producer.KafkaHeader; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.record.TimestampType; import java.util.List; /* * Copyright 2016 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.vertx.kafka.client.consumer; /** * Vert.x Kafka consumer record */ @VertxGen public interface KafkaConsumerRecord<K, V> { /** * @return the topic this record is received from */ String topic(); /** * @return the partition from which this record is received */ int partition(); /** * @return the position of this record in the corresponding Kafka partition. */ long offset(); /** * @return the timestamp of this record */ long timestamp(); /** * @return the timestamp type of this record */ TimestampType timestampType(); /** * @return the checksum (CRC32) of the record. * * @deprecated As of Kafka 0.11.0. Because of the potential for message format conversion on the broker, the * checksum returned by the broker may not match what was computed by the producer. * It is therefore unsafe to depend on this checksum for end-to-end delivery guarantees. Additionally, * message format v2 does not include a record-level checksum (for performance, the record checksum * was replaced with a batch checksum). To maintain compatibility, a partial checksum computed from * the record timestamp, serialized key size, and serialized value size is returned instead, but * this should not be depended on for end-to-end reliability. */ @Deprecated long checksum(); /** * @return the key (or null if no key is specified) */ K key(); /** * @return the value */ V value(); /** * @return the list of consumer record headers */
List<KafkaHeader> headers();
abel533/DBMetadata
DBMetadata-swing/src/main/java/com/github/abel533/view/panel/TableSplitPane.java
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // }
import com.github.abel533.Code; import javax.swing.*; import java.awt.*;
package com.github.abel533.view.panel; public class TableSplitPane extends JSplitPane { private static final long serialVersionUID = 1L; private JTable dbTable; private JTable dbField; public TableSplitPane() { this.setResizeWeight(0.3); JPanel panelTable = new JPanel(); this.setLeftComponent(panelTable); panelTable.setLayout(new BorderLayout(0, 0)); JScrollPane scrollPane = new JScrollPane(); panelTable.add(scrollPane, BorderLayout.CENTER); dbTable = new JTable();
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // } // Path: DBMetadata-swing/src/main/java/com/github/abel533/view/panel/TableSplitPane.java import com.github.abel533.Code; import javax.swing.*; import java.awt.*; package com.github.abel533.view.panel; public class TableSplitPane extends JSplitPane { private static final long serialVersionUID = 1L; private JTable dbTable; private JTable dbField; public TableSplitPane() { this.setResizeWeight(0.3); JPanel panelTable = new JPanel(); this.setLeftComponent(panelTable); panelTable.setLayout(new BorderLayout(0, 0)); JScrollPane scrollPane = new JScrollPane(); panelTable.add(scrollPane, BorderLayout.CENTER); dbTable = new JTable();
dbTable.setFont(Code.TEXT_TABLE);
abel533/DBMetadata
DBMetadata-swing/src/main/java/com/github/abel533/view/panel/SearchPanel.java
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/component/JTextF.java // public class JTextF extends JTextField { // // private static final long serialVersionUID = 1L; // private BufferedImage buffer = null; // // public JTextF() { // super(); // setFont(Code.TEXT_FONT); // } // // @Override // public void paintComponent(Graphics g) { // Component window = this.getTopLevelAncestor(); // if (window instanceof Window && !((Window) window).isOpaque()) { // // This is a translucent window, so we need to draw to a buffer // // first to work around a bug in the DirectDraw rendering in Swing. // int w = this.getWidth(); // int h = this.getHeight(); // if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h) { // // Create a new buffer based on the current size. // GraphicsConfiguration gc = this.getGraphicsConfiguration(); // buffer = gc.createCompatibleImage(w, h, BufferedImage.TRANSLUCENT); // } // // // Use the super class's paintComponent implementation to draw to // // the buffer, then write that buffer to the original Graphics object. // Graphics bufferGraphics = buffer.createGraphics(); // try { // super.paintComponent(bufferGraphics); // } finally { // bufferGraphics.dispose(); // } // g.drawImage(buffer, 0, 0, w, h, 0, 0, w, h, null); // } else { // // This is not a translucent window, so we can call the super class // // implementation directly. // super.paintComponent(g); // } // } // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/I18n.java // public class I18n { // private static final String SUFFIX = ".properties"; // private static ResourceBundle[] resourceBundles; // private static Set<String> baseNameList; // // static { // init(null); // } // // private static void initBaseNameList() { // File[] files = new File(Path.LANGUAGE).listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // if (name.endsWith(SUFFIX)) { // return true; // } // return false; // } // }); // baseNameList = new HashSet<String>(); // for (int i = 0; i < files.length; i++) { // String fileName = files[i].getName(); // int index = fileName.indexOf('_'); // if (index == -1) { // baseNameList.add("language/" + fileName.substring(0, fileName.lastIndexOf('.'))); // } else { // baseNameList.add("language/" + fileName.substring(0, index)); // } // } // } // // /** // * 初始化 - 可以设置语言 // * // * @param locale // */ // public static void init(Locale locale) { // if (locale != null) { // Locale.setDefault(locale); // } // if (baseNameList == null || baseNameList.size() == 0) { // initBaseNameList(); // } // resourceBundles = new ResourceBundle[baseNameList.size()]; // int i = 0; // for (String baseName : baseNameList) { // resourceBundles[i] = ResourceBundle.getBundle(baseName); // i++; // } // } // // public static String key(String key) { // for (int i = 0; i < resourceBundles.length; i++) { // if (resourceBundles[i].containsKey(key)) { // return resourceBundles[i].getString(key); // } // } // throw new RuntimeException("key:" + key + " not exists!"); // } // // /** // * 可配参数,如:查找{0}字段 // * // * @param key // * @param args // * @return // */ // public static String key(String key, Object... args) { // return MessageFormat.format(key(key), args); // } // }
import com.github.abel533.Code; import com.github.abel533.component.JTextF; import com.github.abel533.utils.I18n; import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*;
package com.github.abel533.view.panel; /** * 主界面 - 查询 * * @author liuzh * @since 2015-03-20 */ public class SearchPanel extends JPanel { private static final long serialVersionUID = 1L;
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/component/JTextF.java // public class JTextF extends JTextField { // // private static final long serialVersionUID = 1L; // private BufferedImage buffer = null; // // public JTextF() { // super(); // setFont(Code.TEXT_FONT); // } // // @Override // public void paintComponent(Graphics g) { // Component window = this.getTopLevelAncestor(); // if (window instanceof Window && !((Window) window).isOpaque()) { // // This is a translucent window, so we need to draw to a buffer // // first to work around a bug in the DirectDraw rendering in Swing. // int w = this.getWidth(); // int h = this.getHeight(); // if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h) { // // Create a new buffer based on the current size. // GraphicsConfiguration gc = this.getGraphicsConfiguration(); // buffer = gc.createCompatibleImage(w, h, BufferedImage.TRANSLUCENT); // } // // // Use the super class's paintComponent implementation to draw to // // the buffer, then write that buffer to the original Graphics object. // Graphics bufferGraphics = buffer.createGraphics(); // try { // super.paintComponent(bufferGraphics); // } finally { // bufferGraphics.dispose(); // } // g.drawImage(buffer, 0, 0, w, h, 0, 0, w, h, null); // } else { // // This is not a translucent window, so we can call the super class // // implementation directly. // super.paintComponent(g); // } // } // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/I18n.java // public class I18n { // private static final String SUFFIX = ".properties"; // private static ResourceBundle[] resourceBundles; // private static Set<String> baseNameList; // // static { // init(null); // } // // private static void initBaseNameList() { // File[] files = new File(Path.LANGUAGE).listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // if (name.endsWith(SUFFIX)) { // return true; // } // return false; // } // }); // baseNameList = new HashSet<String>(); // for (int i = 0; i < files.length; i++) { // String fileName = files[i].getName(); // int index = fileName.indexOf('_'); // if (index == -1) { // baseNameList.add("language/" + fileName.substring(0, fileName.lastIndexOf('.'))); // } else { // baseNameList.add("language/" + fileName.substring(0, index)); // } // } // } // // /** // * 初始化 - 可以设置语言 // * // * @param locale // */ // public static void init(Locale locale) { // if (locale != null) { // Locale.setDefault(locale); // } // if (baseNameList == null || baseNameList.size() == 0) { // initBaseNameList(); // } // resourceBundles = new ResourceBundle[baseNameList.size()]; // int i = 0; // for (String baseName : baseNameList) { // resourceBundles[i] = ResourceBundle.getBundle(baseName); // i++; // } // } // // public static String key(String key) { // for (int i = 0; i < resourceBundles.length; i++) { // if (resourceBundles[i].containsKey(key)) { // return resourceBundles[i].getString(key); // } // } // throw new RuntimeException("key:" + key + " not exists!"); // } // // /** // * 可配参数,如:查找{0}字段 // * // * @param key // * @param args // * @return // */ // public static String key(String key, Object... args) { // return MessageFormat.format(key(key), args); // } // } // Path: DBMetadata-swing/src/main/java/com/github/abel533/view/panel/SearchPanel.java import com.github.abel533.Code; import com.github.abel533.component.JTextF; import com.github.abel533.utils.I18n; import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; package com.github.abel533.view.panel; /** * 主界面 - 查询 * * @author liuzh * @since 2015-03-20 */ public class SearchPanel extends JPanel { private static final long serialVersionUID = 1L;
private JTextF textSearchName;
abel533/DBMetadata
DBMetadata-swing/src/main/java/com/github/abel533/view/panel/SearchPanel.java
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/component/JTextF.java // public class JTextF extends JTextField { // // private static final long serialVersionUID = 1L; // private BufferedImage buffer = null; // // public JTextF() { // super(); // setFont(Code.TEXT_FONT); // } // // @Override // public void paintComponent(Graphics g) { // Component window = this.getTopLevelAncestor(); // if (window instanceof Window && !((Window) window).isOpaque()) { // // This is a translucent window, so we need to draw to a buffer // // first to work around a bug in the DirectDraw rendering in Swing. // int w = this.getWidth(); // int h = this.getHeight(); // if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h) { // // Create a new buffer based on the current size. // GraphicsConfiguration gc = this.getGraphicsConfiguration(); // buffer = gc.createCompatibleImage(w, h, BufferedImage.TRANSLUCENT); // } // // // Use the super class's paintComponent implementation to draw to // // the buffer, then write that buffer to the original Graphics object. // Graphics bufferGraphics = buffer.createGraphics(); // try { // super.paintComponent(bufferGraphics); // } finally { // bufferGraphics.dispose(); // } // g.drawImage(buffer, 0, 0, w, h, 0, 0, w, h, null); // } else { // // This is not a translucent window, so we can call the super class // // implementation directly. // super.paintComponent(g); // } // } // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/I18n.java // public class I18n { // private static final String SUFFIX = ".properties"; // private static ResourceBundle[] resourceBundles; // private static Set<String> baseNameList; // // static { // init(null); // } // // private static void initBaseNameList() { // File[] files = new File(Path.LANGUAGE).listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // if (name.endsWith(SUFFIX)) { // return true; // } // return false; // } // }); // baseNameList = new HashSet<String>(); // for (int i = 0; i < files.length; i++) { // String fileName = files[i].getName(); // int index = fileName.indexOf('_'); // if (index == -1) { // baseNameList.add("language/" + fileName.substring(0, fileName.lastIndexOf('.'))); // } else { // baseNameList.add("language/" + fileName.substring(0, index)); // } // } // } // // /** // * 初始化 - 可以设置语言 // * // * @param locale // */ // public static void init(Locale locale) { // if (locale != null) { // Locale.setDefault(locale); // } // if (baseNameList == null || baseNameList.size() == 0) { // initBaseNameList(); // } // resourceBundles = new ResourceBundle[baseNameList.size()]; // int i = 0; // for (String baseName : baseNameList) { // resourceBundles[i] = ResourceBundle.getBundle(baseName); // i++; // } // } // // public static String key(String key) { // for (int i = 0; i < resourceBundles.length; i++) { // if (resourceBundles[i].containsKey(key)) { // return resourceBundles[i].getString(key); // } // } // throw new RuntimeException("key:" + key + " not exists!"); // } // // /** // * 可配参数,如:查找{0}字段 // * // * @param key // * @param args // * @return // */ // public static String key(String key, Object... args) { // return MessageFormat.format(key(key), args); // } // }
import com.github.abel533.Code; import com.github.abel533.component.JTextF; import com.github.abel533.utils.I18n; import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*;
package com.github.abel533.view.panel; /** * 主界面 - 查询 * * @author liuzh * @since 2015-03-20 */ public class SearchPanel extends JPanel { private static final long serialVersionUID = 1L; private JTextF textSearchName; private JTextF textSearchComment; private JTextF textChoose; private JRadioButton radioTypeTable; private JRadioButton radioTypeField; private JCheckBox checkBoxQuickSearch; private JCheckBox checkBoxCaseSensitive; private JRadioButton radioMatchEquals; private JRadioButton radioMatchContains; private JButton btnSearch; private JButton btnCancel; /** * Create the this. */ public SearchPanel() { this.setPreferredSize(new Dimension(811, 114)); this.setLayout(new BorderLayout(0, 0)); JPanel panel_2 = new JPanel(); panel_2.setPreferredSize(new Dimension(250, 10)); this.add(panel_2, BorderLayout.EAST); panel_2.setLayout(null);
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/component/JTextF.java // public class JTextF extends JTextField { // // private static final long serialVersionUID = 1L; // private BufferedImage buffer = null; // // public JTextF() { // super(); // setFont(Code.TEXT_FONT); // } // // @Override // public void paintComponent(Graphics g) { // Component window = this.getTopLevelAncestor(); // if (window instanceof Window && !((Window) window).isOpaque()) { // // This is a translucent window, so we need to draw to a buffer // // first to work around a bug in the DirectDraw rendering in Swing. // int w = this.getWidth(); // int h = this.getHeight(); // if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h) { // // Create a new buffer based on the current size. // GraphicsConfiguration gc = this.getGraphicsConfiguration(); // buffer = gc.createCompatibleImage(w, h, BufferedImage.TRANSLUCENT); // } // // // Use the super class's paintComponent implementation to draw to // // the buffer, then write that buffer to the original Graphics object. // Graphics bufferGraphics = buffer.createGraphics(); // try { // super.paintComponent(bufferGraphics); // } finally { // bufferGraphics.dispose(); // } // g.drawImage(buffer, 0, 0, w, h, 0, 0, w, h, null); // } else { // // This is not a translucent window, so we can call the super class // // implementation directly. // super.paintComponent(g); // } // } // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/I18n.java // public class I18n { // private static final String SUFFIX = ".properties"; // private static ResourceBundle[] resourceBundles; // private static Set<String> baseNameList; // // static { // init(null); // } // // private static void initBaseNameList() { // File[] files = new File(Path.LANGUAGE).listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // if (name.endsWith(SUFFIX)) { // return true; // } // return false; // } // }); // baseNameList = new HashSet<String>(); // for (int i = 0; i < files.length; i++) { // String fileName = files[i].getName(); // int index = fileName.indexOf('_'); // if (index == -1) { // baseNameList.add("language/" + fileName.substring(0, fileName.lastIndexOf('.'))); // } else { // baseNameList.add("language/" + fileName.substring(0, index)); // } // } // } // // /** // * 初始化 - 可以设置语言 // * // * @param locale // */ // public static void init(Locale locale) { // if (locale != null) { // Locale.setDefault(locale); // } // if (baseNameList == null || baseNameList.size() == 0) { // initBaseNameList(); // } // resourceBundles = new ResourceBundle[baseNameList.size()]; // int i = 0; // for (String baseName : baseNameList) { // resourceBundles[i] = ResourceBundle.getBundle(baseName); // i++; // } // } // // public static String key(String key) { // for (int i = 0; i < resourceBundles.length; i++) { // if (resourceBundles[i].containsKey(key)) { // return resourceBundles[i].getString(key); // } // } // throw new RuntimeException("key:" + key + " not exists!"); // } // // /** // * 可配参数,如:查找{0}字段 // * // * @param key // * @param args // * @return // */ // public static String key(String key, Object... args) { // return MessageFormat.format(key(key), args); // } // } // Path: DBMetadata-swing/src/main/java/com/github/abel533/view/panel/SearchPanel.java import com.github.abel533.Code; import com.github.abel533.component.JTextF; import com.github.abel533.utils.I18n; import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; package com.github.abel533.view.panel; /** * 主界面 - 查询 * * @author liuzh * @since 2015-03-20 */ public class SearchPanel extends JPanel { private static final long serialVersionUID = 1L; private JTextF textSearchName; private JTextF textSearchComment; private JTextF textChoose; private JRadioButton radioTypeTable; private JRadioButton radioTypeField; private JCheckBox checkBoxQuickSearch; private JCheckBox checkBoxCaseSensitive; private JRadioButton radioMatchEquals; private JRadioButton radioMatchContains; private JButton btnSearch; private JButton btnCancel; /** * Create the this. */ public SearchPanel() { this.setPreferredSize(new Dimension(811, 114)); this.setLayout(new BorderLayout(0, 0)); JPanel panel_2 = new JPanel(); panel_2.setPreferredSize(new Dimension(250, 10)); this.add(panel_2, BorderLayout.EAST); panel_2.setLayout(null);
btnSearch = new JButton(I18n.key("tools.main.btn.search"));
abel533/DBMetadata
DBMetadata-swing/src/main/java/com/github/abel533/view/panel/SearchPanel.java
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/component/JTextF.java // public class JTextF extends JTextField { // // private static final long serialVersionUID = 1L; // private BufferedImage buffer = null; // // public JTextF() { // super(); // setFont(Code.TEXT_FONT); // } // // @Override // public void paintComponent(Graphics g) { // Component window = this.getTopLevelAncestor(); // if (window instanceof Window && !((Window) window).isOpaque()) { // // This is a translucent window, so we need to draw to a buffer // // first to work around a bug in the DirectDraw rendering in Swing. // int w = this.getWidth(); // int h = this.getHeight(); // if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h) { // // Create a new buffer based on the current size. // GraphicsConfiguration gc = this.getGraphicsConfiguration(); // buffer = gc.createCompatibleImage(w, h, BufferedImage.TRANSLUCENT); // } // // // Use the super class's paintComponent implementation to draw to // // the buffer, then write that buffer to the original Graphics object. // Graphics bufferGraphics = buffer.createGraphics(); // try { // super.paintComponent(bufferGraphics); // } finally { // bufferGraphics.dispose(); // } // g.drawImage(buffer, 0, 0, w, h, 0, 0, w, h, null); // } else { // // This is not a translucent window, so we can call the super class // // implementation directly. // super.paintComponent(g); // } // } // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/I18n.java // public class I18n { // private static final String SUFFIX = ".properties"; // private static ResourceBundle[] resourceBundles; // private static Set<String> baseNameList; // // static { // init(null); // } // // private static void initBaseNameList() { // File[] files = new File(Path.LANGUAGE).listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // if (name.endsWith(SUFFIX)) { // return true; // } // return false; // } // }); // baseNameList = new HashSet<String>(); // for (int i = 0; i < files.length; i++) { // String fileName = files[i].getName(); // int index = fileName.indexOf('_'); // if (index == -1) { // baseNameList.add("language/" + fileName.substring(0, fileName.lastIndexOf('.'))); // } else { // baseNameList.add("language/" + fileName.substring(0, index)); // } // } // } // // /** // * 初始化 - 可以设置语言 // * // * @param locale // */ // public static void init(Locale locale) { // if (locale != null) { // Locale.setDefault(locale); // } // if (baseNameList == null || baseNameList.size() == 0) { // initBaseNameList(); // } // resourceBundles = new ResourceBundle[baseNameList.size()]; // int i = 0; // for (String baseName : baseNameList) { // resourceBundles[i] = ResourceBundle.getBundle(baseName); // i++; // } // } // // public static String key(String key) { // for (int i = 0; i < resourceBundles.length; i++) { // if (resourceBundles[i].containsKey(key)) { // return resourceBundles[i].getString(key); // } // } // throw new RuntimeException("key:" + key + " not exists!"); // } // // /** // * 可配参数,如:查找{0}字段 // * // * @param key // * @param args // * @return // */ // public static String key(String key, Object... args) { // return MessageFormat.format(key(key), args); // } // }
import com.github.abel533.Code; import com.github.abel533.component.JTextF; import com.github.abel533.utils.I18n; import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*;
package com.github.abel533.view.panel; /** * 主界面 - 查询 * * @author liuzh * @since 2015-03-20 */ public class SearchPanel extends JPanel { private static final long serialVersionUID = 1L; private JTextF textSearchName; private JTextF textSearchComment; private JTextF textChoose; private JRadioButton radioTypeTable; private JRadioButton radioTypeField; private JCheckBox checkBoxQuickSearch; private JCheckBox checkBoxCaseSensitive; private JRadioButton radioMatchEquals; private JRadioButton radioMatchContains; private JButton btnSearch; private JButton btnCancel; /** * Create the this. */ public SearchPanel() { this.setPreferredSize(new Dimension(811, 114)); this.setLayout(new BorderLayout(0, 0)); JPanel panel_2 = new JPanel(); panel_2.setPreferredSize(new Dimension(250, 10)); this.add(panel_2, BorderLayout.EAST); panel_2.setLayout(null); btnSearch = new JButton(I18n.key("tools.main.btn.search")); btnSearch.setBounds(29, 0, 124, 71); panel_2.add(btnSearch);
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/component/JTextF.java // public class JTextF extends JTextField { // // private static final long serialVersionUID = 1L; // private BufferedImage buffer = null; // // public JTextF() { // super(); // setFont(Code.TEXT_FONT); // } // // @Override // public void paintComponent(Graphics g) { // Component window = this.getTopLevelAncestor(); // if (window instanceof Window && !((Window) window).isOpaque()) { // // This is a translucent window, so we need to draw to a buffer // // first to work around a bug in the DirectDraw rendering in Swing. // int w = this.getWidth(); // int h = this.getHeight(); // if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h) { // // Create a new buffer based on the current size. // GraphicsConfiguration gc = this.getGraphicsConfiguration(); // buffer = gc.createCompatibleImage(w, h, BufferedImage.TRANSLUCENT); // } // // // Use the super class's paintComponent implementation to draw to // // the buffer, then write that buffer to the original Graphics object. // Graphics bufferGraphics = buffer.createGraphics(); // try { // super.paintComponent(bufferGraphics); // } finally { // bufferGraphics.dispose(); // } // g.drawImage(buffer, 0, 0, w, h, 0, 0, w, h, null); // } else { // // This is not a translucent window, so we can call the super class // // implementation directly. // super.paintComponent(g); // } // } // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/I18n.java // public class I18n { // private static final String SUFFIX = ".properties"; // private static ResourceBundle[] resourceBundles; // private static Set<String> baseNameList; // // static { // init(null); // } // // private static void initBaseNameList() { // File[] files = new File(Path.LANGUAGE).listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // if (name.endsWith(SUFFIX)) { // return true; // } // return false; // } // }); // baseNameList = new HashSet<String>(); // for (int i = 0; i < files.length; i++) { // String fileName = files[i].getName(); // int index = fileName.indexOf('_'); // if (index == -1) { // baseNameList.add("language/" + fileName.substring(0, fileName.lastIndexOf('.'))); // } else { // baseNameList.add("language/" + fileName.substring(0, index)); // } // } // } // // /** // * 初始化 - 可以设置语言 // * // * @param locale // */ // public static void init(Locale locale) { // if (locale != null) { // Locale.setDefault(locale); // } // if (baseNameList == null || baseNameList.size() == 0) { // initBaseNameList(); // } // resourceBundles = new ResourceBundle[baseNameList.size()]; // int i = 0; // for (String baseName : baseNameList) { // resourceBundles[i] = ResourceBundle.getBundle(baseName); // i++; // } // } // // public static String key(String key) { // for (int i = 0; i < resourceBundles.length; i++) { // if (resourceBundles[i].containsKey(key)) { // return resourceBundles[i].getString(key); // } // } // throw new RuntimeException("key:" + key + " not exists!"); // } // // /** // * 可配参数,如:查找{0}字段 // * // * @param key // * @param args // * @return // */ // public static String key(String key, Object... args) { // return MessageFormat.format(key(key), args); // } // } // Path: DBMetadata-swing/src/main/java/com/github/abel533/view/panel/SearchPanel.java import com.github.abel533.Code; import com.github.abel533.component.JTextF; import com.github.abel533.utils.I18n; import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; package com.github.abel533.view.panel; /** * 主界面 - 查询 * * @author liuzh * @since 2015-03-20 */ public class SearchPanel extends JPanel { private static final long serialVersionUID = 1L; private JTextF textSearchName; private JTextF textSearchComment; private JTextF textChoose; private JRadioButton radioTypeTable; private JRadioButton radioTypeField; private JCheckBox checkBoxQuickSearch; private JCheckBox checkBoxCaseSensitive; private JRadioButton radioMatchEquals; private JRadioButton radioMatchContains; private JButton btnSearch; private JButton btnCancel; /** * Create the this. */ public SearchPanel() { this.setPreferredSize(new Dimension(811, 114)); this.setLayout(new BorderLayout(0, 0)); JPanel panel_2 = new JPanel(); panel_2.setPreferredSize(new Dimension(250, 10)); this.add(panel_2, BorderLayout.EAST); panel_2.setLayout(null); btnSearch = new JButton(I18n.key("tools.main.btn.search")); btnSearch.setBounds(29, 0, 124, 71); panel_2.add(btnSearch);
btnSearch.setFont(Code.TEXT_BUTTON);
abel533/DBMetadata
DBMetadata-swing/src/main/java/com/github/abel533/view/panel/MsgPane.java
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // }
import com.github.abel533.Code; import javax.swing.*; import java.awt.*;
package com.github.abel533.view.panel; public class MsgPane extends JScrollPane { private static final long serialVersionUID = 1L; private JTextArea loadMsg; public MsgPane() { loadMsg = new JTextArea();
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // } // Path: DBMetadata-swing/src/main/java/com/github/abel533/view/panel/MsgPane.java import com.github.abel533.Code; import javax.swing.*; import java.awt.*; package com.github.abel533.view.panel; public class MsgPane extends JScrollPane { private static final long serialVersionUID = 1L; private JTextArea loadMsg; public MsgPane() { loadMsg = new JTextArea();
loadMsg.setFont(Code.TEXT_MSG);
abel533/DBMetadata
DBMetadata-swing/src/main/java/com/github/abel533/component/JTextF.java
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // }
import com.github.abel533.Code; import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage;
package com.github.abel533.component; /** * 解决切换输入法导致白屏问题<br> * 参考:http://stackoverflow.com/questions/14374111/input-method-removes-transparent-effect-from-jframe-in-swing * * @author liuzh */ public class JTextF extends JTextField { private static final long serialVersionUID = 1L; private BufferedImage buffer = null; public JTextF() { super();
// Path: DBMetadata-swing/src/main/java/com/github/abel533/Code.java // public class Code { // public static Font TEXT_MSG = new Font("Monospaced", Font.PLAIN, 10); // public static Font TEXT_FONT = new Font(I18n.key("tools.text.font"), Font.PLAIN, 14); // public static Font TEXT_TABLE = new Font(I18n.key("tools.text.font"), Font.PLAIN, 12); // public static Font TEXT_BUTTON = new Font(I18n.key("tools.text.font"), Font.BOLD, 14); // } // Path: DBMetadata-swing/src/main/java/com/github/abel533/component/JTextF.java import com.github.abel533.Code; import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; package com.github.abel533.component; /** * 解决切换输入法导致白屏问题<br> * 参考:http://stackoverflow.com/questions/14374111/input-method-removes-transparent-effect-from-jframe-in-swing * * @author liuzh */ public class JTextF extends JTextField { private static final long serialVersionUID = 1L; private BufferedImage buffer = null; public JTextF() { super();
setFont(Code.TEXT_FONT);
abel533/DBMetadata
DBMetadata-swing/src/main/java/com/github/abel533/component/DBServerList.java
// Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/I18n.java // public class I18n { // private static final String SUFFIX = ".properties"; // private static ResourceBundle[] resourceBundles; // private static Set<String> baseNameList; // // static { // init(null); // } // // private static void initBaseNameList() { // File[] files = new File(Path.LANGUAGE).listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // if (name.endsWith(SUFFIX)) { // return true; // } // return false; // } // }); // baseNameList = new HashSet<String>(); // for (int i = 0; i < files.length; i++) { // String fileName = files[i].getName(); // int index = fileName.indexOf('_'); // if (index == -1) { // baseNameList.add("language/" + fileName.substring(0, fileName.lastIndexOf('.'))); // } else { // baseNameList.add("language/" + fileName.substring(0, index)); // } // } // } // // /** // * 初始化 - 可以设置语言 // * // * @param locale // */ // public static void init(Locale locale) { // if (locale != null) { // Locale.setDefault(locale); // } // if (baseNameList == null || baseNameList.size() == 0) { // initBaseNameList(); // } // resourceBundles = new ResourceBundle[baseNameList.size()]; // int i = 0; // for (String baseName : baseNameList) { // resourceBundles[i] = ResourceBundle.getBundle(baseName); // i++; // } // } // // public static String key(String key) { // for (int i = 0; i < resourceBundles.length; i++) { // if (resourceBundles[i].containsKey(key)) { // return resourceBundles[i].getString(key); // } // } // throw new RuntimeException("key:" + key + " not exists!"); // } // // /** // * 可配参数,如:查找{0}字段 // * // * @param key // * @param args // * @return // */ // public static String key(String key, Object... args) { // return MessageFormat.format(key(key), args); // } // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/Path.java // public abstract class Path { // // public static final String ROOT; // public static final String LANGUAGE; // public static final String db_json; // // static { // String root = null; // try { // root = getRealPath(); // } catch (Exception e) { // e.printStackTrace(); // root = getProjectPath(); // } // if (root != null) { // root = root.replaceAll("\\\\", "/"); // } // ROOT = root + "/"; // LANGUAGE = ROOT + "language/"; // db_json = ROOT + "/db.json"; // } // // public static String getProjectPath() { // java.net.URL url = Path.class.getProtectionDomain().getCodeSource() // .getLocation(); // String filePath = null; // try { // filePath = java.net.URLDecoder.decode(url.getPath(), "utf-8"); // } catch (Exception e) { // e.printStackTrace(); // } // if (filePath.endsWith(".jar")) // filePath = filePath.substring(0, filePath.lastIndexOf("/") + 1); // java.io.File file = new java.io.File(filePath); // filePath = file.getAbsolutePath(); // return filePath; // } // // public static String getRealPath() throws Exception { // String realPath = Path.class.getClassLoader().getResource("").getFile(); // java.io.File file = new java.io.File(realPath); // realPath = file.getAbsolutePath(); // realPath = java.net.URLDecoder.decode(realPath, "utf-8"); // return realPath; // } // }
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; import com.github.abel533.utils.I18n; import com.github.abel533.utils.Path; import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.HashSet; import java.util.Set;
package com.github.abel533.component; public class DBServerList { private Set<DBServer> servers; private String selected; public DBServerList() { this.servers = new HashSet<DBServer>(); } public Set<DBServer> getServers() { return servers; } public void setServers(Set<DBServer> servers) { this.servers = servers; } public String getSelected() { return selected; } public void setSelected(String selected) { this.selected = selected; } public void toDBJson() { FileWriter writer = null; try {
// Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/I18n.java // public class I18n { // private static final String SUFFIX = ".properties"; // private static ResourceBundle[] resourceBundles; // private static Set<String> baseNameList; // // static { // init(null); // } // // private static void initBaseNameList() { // File[] files = new File(Path.LANGUAGE).listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // if (name.endsWith(SUFFIX)) { // return true; // } // return false; // } // }); // baseNameList = new HashSet<String>(); // for (int i = 0; i < files.length; i++) { // String fileName = files[i].getName(); // int index = fileName.indexOf('_'); // if (index == -1) { // baseNameList.add("language/" + fileName.substring(0, fileName.lastIndexOf('.'))); // } else { // baseNameList.add("language/" + fileName.substring(0, index)); // } // } // } // // /** // * 初始化 - 可以设置语言 // * // * @param locale // */ // public static void init(Locale locale) { // if (locale != null) { // Locale.setDefault(locale); // } // if (baseNameList == null || baseNameList.size() == 0) { // initBaseNameList(); // } // resourceBundles = new ResourceBundle[baseNameList.size()]; // int i = 0; // for (String baseName : baseNameList) { // resourceBundles[i] = ResourceBundle.getBundle(baseName); // i++; // } // } // // public static String key(String key) { // for (int i = 0; i < resourceBundles.length; i++) { // if (resourceBundles[i].containsKey(key)) { // return resourceBundles[i].getString(key); // } // } // throw new RuntimeException("key:" + key + " not exists!"); // } // // /** // * 可配参数,如:查找{0}字段 // * // * @param key // * @param args // * @return // */ // public static String key(String key, Object... args) { // return MessageFormat.format(key(key), args); // } // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/Path.java // public abstract class Path { // // public static final String ROOT; // public static final String LANGUAGE; // public static final String db_json; // // static { // String root = null; // try { // root = getRealPath(); // } catch (Exception e) { // e.printStackTrace(); // root = getProjectPath(); // } // if (root != null) { // root = root.replaceAll("\\\\", "/"); // } // ROOT = root + "/"; // LANGUAGE = ROOT + "language/"; // db_json = ROOT + "/db.json"; // } // // public static String getProjectPath() { // java.net.URL url = Path.class.getProtectionDomain().getCodeSource() // .getLocation(); // String filePath = null; // try { // filePath = java.net.URLDecoder.decode(url.getPath(), "utf-8"); // } catch (Exception e) { // e.printStackTrace(); // } // if (filePath.endsWith(".jar")) // filePath = filePath.substring(0, filePath.lastIndexOf("/") + 1); // java.io.File file = new java.io.File(filePath); // filePath = file.getAbsolutePath(); // return filePath; // } // // public static String getRealPath() throws Exception { // String realPath = Path.class.getClassLoader().getResource("").getFile(); // java.io.File file = new java.io.File(realPath); // realPath = file.getAbsolutePath(); // realPath = java.net.URLDecoder.decode(realPath, "utf-8"); // return realPath; // } // } // Path: DBMetadata-swing/src/main/java/com/github/abel533/component/DBServerList.java import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; import com.github.abel533.utils.I18n; import com.github.abel533.utils.Path; import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.HashSet; import java.util.Set; package com.github.abel533.component; public class DBServerList { private Set<DBServer> servers; private String selected; public DBServerList() { this.servers = new HashSet<DBServer>(); } public Set<DBServer> getServers() { return servers; } public void setServers(Set<DBServer> servers) { this.servers = servers; } public String getSelected() { return selected; } public void setSelected(String selected) { this.selected = selected; } public void toDBJson() { FileWriter writer = null; try {
writer = new FileWriter(Path.db_json);
abel533/DBMetadata
DBMetadata-swing/src/main/java/com/github/abel533/component/DBServerList.java
// Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/I18n.java // public class I18n { // private static final String SUFFIX = ".properties"; // private static ResourceBundle[] resourceBundles; // private static Set<String> baseNameList; // // static { // init(null); // } // // private static void initBaseNameList() { // File[] files = new File(Path.LANGUAGE).listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // if (name.endsWith(SUFFIX)) { // return true; // } // return false; // } // }); // baseNameList = new HashSet<String>(); // for (int i = 0; i < files.length; i++) { // String fileName = files[i].getName(); // int index = fileName.indexOf('_'); // if (index == -1) { // baseNameList.add("language/" + fileName.substring(0, fileName.lastIndexOf('.'))); // } else { // baseNameList.add("language/" + fileName.substring(0, index)); // } // } // } // // /** // * 初始化 - 可以设置语言 // * // * @param locale // */ // public static void init(Locale locale) { // if (locale != null) { // Locale.setDefault(locale); // } // if (baseNameList == null || baseNameList.size() == 0) { // initBaseNameList(); // } // resourceBundles = new ResourceBundle[baseNameList.size()]; // int i = 0; // for (String baseName : baseNameList) { // resourceBundles[i] = ResourceBundle.getBundle(baseName); // i++; // } // } // // public static String key(String key) { // for (int i = 0; i < resourceBundles.length; i++) { // if (resourceBundles[i].containsKey(key)) { // return resourceBundles[i].getString(key); // } // } // throw new RuntimeException("key:" + key + " not exists!"); // } // // /** // * 可配参数,如:查找{0}字段 // * // * @param key // * @param args // * @return // */ // public static String key(String key, Object... args) { // return MessageFormat.format(key(key), args); // } // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/Path.java // public abstract class Path { // // public static final String ROOT; // public static final String LANGUAGE; // public static final String db_json; // // static { // String root = null; // try { // root = getRealPath(); // } catch (Exception e) { // e.printStackTrace(); // root = getProjectPath(); // } // if (root != null) { // root = root.replaceAll("\\\\", "/"); // } // ROOT = root + "/"; // LANGUAGE = ROOT + "language/"; // db_json = ROOT + "/db.json"; // } // // public static String getProjectPath() { // java.net.URL url = Path.class.getProtectionDomain().getCodeSource() // .getLocation(); // String filePath = null; // try { // filePath = java.net.URLDecoder.decode(url.getPath(), "utf-8"); // } catch (Exception e) { // e.printStackTrace(); // } // if (filePath.endsWith(".jar")) // filePath = filePath.substring(0, filePath.lastIndexOf("/") + 1); // java.io.File file = new java.io.File(filePath); // filePath = file.getAbsolutePath(); // return filePath; // } // // public static String getRealPath() throws Exception { // String realPath = Path.class.getClassLoader().getResource("").getFile(); // java.io.File file = new java.io.File(realPath); // realPath = file.getAbsolutePath(); // realPath = java.net.URLDecoder.decode(realPath, "utf-8"); // return realPath; // } // }
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; import com.github.abel533.utils.I18n; import com.github.abel533.utils.Path; import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.HashSet; import java.util.Set;
package com.github.abel533.component; public class DBServerList { private Set<DBServer> servers; private String selected; public DBServerList() { this.servers = new HashSet<DBServer>(); } public Set<DBServer> getServers() { return servers; } public void setServers(Set<DBServer> servers) { this.servers = servers; } public String getSelected() { return selected; } public void setSelected(String selected) { this.selected = selected; } public void toDBJson() { FileWriter writer = null; try { writer = new FileWriter(Path.db_json); JSON.writeJSONStringTo(this, writer, SerializerFeature.PrettyFormat); } catch (IOException e) {
// Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/I18n.java // public class I18n { // private static final String SUFFIX = ".properties"; // private static ResourceBundle[] resourceBundles; // private static Set<String> baseNameList; // // static { // init(null); // } // // private static void initBaseNameList() { // File[] files = new File(Path.LANGUAGE).listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // if (name.endsWith(SUFFIX)) { // return true; // } // return false; // } // }); // baseNameList = new HashSet<String>(); // for (int i = 0; i < files.length; i++) { // String fileName = files[i].getName(); // int index = fileName.indexOf('_'); // if (index == -1) { // baseNameList.add("language/" + fileName.substring(0, fileName.lastIndexOf('.'))); // } else { // baseNameList.add("language/" + fileName.substring(0, index)); // } // } // } // // /** // * 初始化 - 可以设置语言 // * // * @param locale // */ // public static void init(Locale locale) { // if (locale != null) { // Locale.setDefault(locale); // } // if (baseNameList == null || baseNameList.size() == 0) { // initBaseNameList(); // } // resourceBundles = new ResourceBundle[baseNameList.size()]; // int i = 0; // for (String baseName : baseNameList) { // resourceBundles[i] = ResourceBundle.getBundle(baseName); // i++; // } // } // // public static String key(String key) { // for (int i = 0; i < resourceBundles.length; i++) { // if (resourceBundles[i].containsKey(key)) { // return resourceBundles[i].getString(key); // } // } // throw new RuntimeException("key:" + key + " not exists!"); // } // // /** // * 可配参数,如:查找{0}字段 // * // * @param key // * @param args // * @return // */ // public static String key(String key, Object... args) { // return MessageFormat.format(key(key), args); // } // } // // Path: DBMetadata-swing/src/main/java/com/github/abel533/utils/Path.java // public abstract class Path { // // public static final String ROOT; // public static final String LANGUAGE; // public static final String db_json; // // static { // String root = null; // try { // root = getRealPath(); // } catch (Exception e) { // e.printStackTrace(); // root = getProjectPath(); // } // if (root != null) { // root = root.replaceAll("\\\\", "/"); // } // ROOT = root + "/"; // LANGUAGE = ROOT + "language/"; // db_json = ROOT + "/db.json"; // } // // public static String getProjectPath() { // java.net.URL url = Path.class.getProtectionDomain().getCodeSource() // .getLocation(); // String filePath = null; // try { // filePath = java.net.URLDecoder.decode(url.getPath(), "utf-8"); // } catch (Exception e) { // e.printStackTrace(); // } // if (filePath.endsWith(".jar")) // filePath = filePath.substring(0, filePath.lastIndexOf("/") + 1); // java.io.File file = new java.io.File(filePath); // filePath = file.getAbsolutePath(); // return filePath; // } // // public static String getRealPath() throws Exception { // String realPath = Path.class.getClassLoader().getResource("").getFile(); // java.io.File file = new java.io.File(realPath); // realPath = file.getAbsolutePath(); // realPath = java.net.URLDecoder.decode(realPath, "utf-8"); // return realPath; // } // } // Path: DBMetadata-swing/src/main/java/com/github/abel533/component/DBServerList.java import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; import com.github.abel533.utils.I18n; import com.github.abel533.utils.Path; import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.HashSet; import java.util.Set; package com.github.abel533.component; public class DBServerList { private Set<DBServer> servers; private String selected; public DBServerList() { this.servers = new HashSet<DBServer>(); } public Set<DBServer> getServers() { return servers; } public void setServers(Set<DBServer> servers) { this.servers = servers; } public String getSelected() { return selected; } public void setSelected(String selected) { this.selected = selected; } public void toDBJson() { FileWriter writer = null; try { writer = new FileWriter(Path.db_json); JSON.writeJSONStringTo(this, writer, SerializerFeature.PrettyFormat); } catch (IOException e) {
throw new RuntimeException(I18n.key("tools.login.save.failure"));