@Test public void testGetCode() { final String expectedCode = "006"; final List<Long> seqNumber = new ArrayList<Long>(); seqNumber.add(Long.valueOf("6")); when(sequenceGenService.getIds(any(Integer.class), any(String.class))).thenReturn(seqNumber); final String actualCode = assetCommonService.getCode("%03d", Sequence.ASSETCATEGORYCODESEQUENCE); assertEquals(expectedCode, actualCode); }
public String getCode(final String codeFormat, final Sequence sequence) { final List<Long> codeSequence = sequenceGenService.getIds(1, sequence.toString()); log.debug("code sequence result :: " + codeSequence); if (codeSequence != null && !codeSequence.isEmpty()) { final StringBuilder code = new StringBuilder(String.format(codeFormat, codeSequence.get(0))); log.debug("Generated code :: " + code); return code.toString(); } else throw new RuntimeException("Code is not generated."); }
AssetCommonService { public String getCode(final String codeFormat, final Sequence sequence) { final List<Long> codeSequence = sequenceGenService.getIds(1, sequence.toString()); log.debug("code sequence result :: " + codeSequence); if (codeSequence != null && !codeSequence.isEmpty()) { final StringBuilder code = new StringBuilder(String.format(codeFormat, codeSequence.get(0))); log.debug("Generated code :: " + code); return code.toString(); } else throw new RuntimeException("Code is not generated."); } }
AssetCommonService { public String getCode(final String codeFormat, final Sequence sequence) { final List<Long> codeSequence = sequenceGenService.getIds(1, sequence.toString()); log.debug("code sequence result :: " + codeSequence); if (codeSequence != null && !codeSequence.isEmpty()) { final StringBuilder code = new StringBuilder(String.format(codeFormat, codeSequence.get(0))); log.debug("Generated code :: " + code); return code.toString(); } else throw new RuntimeException("Code is not generated."); }  }
AssetCommonService { public String getCode(final String codeFormat, final Sequence sequence) { final List<Long> codeSequence = sequenceGenService.getIds(1, sequence.toString()); log.debug("code sequence result :: " + codeSequence); if (codeSequence != null && !codeSequence.isEmpty()) { final StringBuilder code = new StringBuilder(String.format(codeFormat, codeSequence.get(0))); log.debug("Generated code :: " + code); return code.toString(); } else throw new RuntimeException("Code is not generated."); }  ErrorResponse populateErrors(final BindingResult errors); Double getDepreciationRate(final Double depreciationRate); void validateDepreciationRateValue(final Double depreciationRate); AuditDetails getAuditDetails(final RequestInfo requestInfo); String getCode(final String codeFormat, final Sequence sequence); Long getNextId(final Sequence sequence); }
AssetCommonService { public String getCode(final String codeFormat, final Sequence sequence) { final List<Long> codeSequence = sequenceGenService.getIds(1, sequence.toString()); log.debug("code sequence result :: " + codeSequence); if (codeSequence != null && !codeSequence.isEmpty()) { final StringBuilder code = new StringBuilder(String.format(codeFormat, codeSequence.get(0))); log.debug("Generated code :: " + code); return code.toString(); } else throw new RuntimeException("Code is not generated."); }  ErrorResponse populateErrors(final BindingResult errors); Double getDepreciationRate(final Double depreciationRate); void validateDepreciationRateValue(final Double depreciationRate); AuditDetails getAuditDetails(final RequestInfo requestInfo); String getCode(final String codeFormat, final Sequence sequence); Long getNextId(final Sequence sequence);  }