@Test public void shouldExtractMessageContent() throws ParseException, MessageContentExtractionException { SupportCaseExtractionStrategy strategy = new SupportCaseExtractionStrategy(); IncomingMessage message = new IncomingMessage(); message.setKey(" SUPPORT"); message.setTime("2011-06-25 09:30:29 "); message.setText("SUPPORT 123 Cannot Upload Forms "); message.setNumber("+233123456789 "); SupportCase supportCase = strategy.extractFrom(message); assertEquals("123",supportCase.getRaisedBy()); assertEquals("+233123456789",supportCase.getPhoneNumber()); assertEquals("2011-06-25 09:30:29",supportCase.getDateRaisedOn()); assertEquals("Cannot Upload Forms",supportCase.getDescription()); }
public SupportCase extractFrom(IncomingMessage message) { try { String dateRaisedOn = message.extractDateWith(this); String phoneNumber = message.extractPhoneNumberWith(this); String sender = message.extractSenderWith(this); String description = message.extractDescriptionWith(this); return new SupportCase(sender,phoneNumber,dateRaisedOn,description); } catch (Exception ex){ return new SupportCase(); } }
SupportCaseExtractionStrategy implements MessageContentExtractionStrategy { public SupportCase extractFrom(IncomingMessage message) { try { String dateRaisedOn = message.extractDateWith(this); String phoneNumber = message.extractPhoneNumberWith(this); String sender = message.extractSenderWith(this); String description = message.extractDescriptionWith(this); return new SupportCase(sender,phoneNumber,dateRaisedOn,description); } catch (Exception ex){ return new SupportCase(); } } }
SupportCaseExtractionStrategy implements MessageContentExtractionStrategy { public SupportCase extractFrom(IncomingMessage message) { try { String dateRaisedOn = message.extractDateWith(this); String phoneNumber = message.extractPhoneNumberWith(this); String sender = message.extractSenderWith(this); String description = message.extractDescriptionWith(this); return new SupportCase(sender,phoneNumber,dateRaisedOn,description); } catch (Exception ex){ return new SupportCase(); } }  }
SupportCaseExtractionStrategy implements MessageContentExtractionStrategy { public SupportCase extractFrom(IncomingMessage message) { try { String dateRaisedOn = message.extractDateWith(this); String phoneNumber = message.extractPhoneNumberWith(this); String sender = message.extractSenderWith(this); String description = message.extractDescriptionWith(this); return new SupportCase(sender,phoneNumber,dateRaisedOn,description); } catch (Exception ex){ return new SupportCase(); } }  SupportCase extractFrom(IncomingMessage message); String extractDateFrom(String time); String extractPhoneNumberFrom(String phoneNumber); String extractSenderFrom(String text); String extractDescriptionFrom(String text); }
SupportCaseExtractionStrategy implements MessageContentExtractionStrategy { public SupportCase extractFrom(IncomingMessage message) { try { String dateRaisedOn = message.extractDateWith(this); String phoneNumber = message.extractPhoneNumberWith(this); String sender = message.extractSenderWith(this); String description = message.extractDescriptionWith(this); return new SupportCase(sender,phoneNumber,dateRaisedOn,description); } catch (Exception ex){ return new SupportCase(); } }  SupportCase extractFrom(IncomingMessage message); String extractDateFrom(String time); String extractPhoneNumberFrom(String phoneNumber); String extractSenderFrom(String text); String extractDescriptionFrom(String text);  }